用emeditor宏制作图片格式词典

用emeditor宏制作图片格式词典
1,字头自动生成
准备好字头,
格式是 字头 页码
注意页码不要超过5位数字(一般来说9999页已经足够了)

字头	123
词头	23
生	9
成	11
器	45

01

//在文档末尾增加一个空行,保证EOF在空行。
document.selection.EndOfDocument(false);
document.selection.NewLine(1);

//号码补零统一为四位数
document.selection.Replace("^(.*?)\\t(\\d{1})$","\\1\\t000\\2",eeReplaceAll | eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);
document.selection.Replace("^(.*?)\\t(\\d{2})$","\\1\\t00\\2",eeReplaceAll | eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);
document.selection.Replace("^(.*?)\\t(\\d{3})$","\\1\\t0\\2",eeReplaceAll | eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);
document.selection.Replace("^(.*?)\\t(\\d{4})$","</>\\n\\1\\n<CT>\\1</CT>\\t<img src=\"\\2.png\"><br><a href=\"entry://\\2\">【查看图片】</a>",eeReplaceAll | eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);

// 跳转文档开头 ctrl+home--------删去 分隔标志</>
document.selection.StartOfDocument(false);
document.selection.Replace("</>\\n","",eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);

// 跳转文档末尾 ctrl+end--------添加 分隔标志</>
document.selection.EndOfDocument(false);
document.selection.Text="</>";
document.selection.NewLine(1);
document.selection.Replace("^[ \t ]*$\\n","",eeReplaceAll | eeFindReplaceRegExp,0);

2,页码自动生成
新建一个文档

var pg=prompt("你需要多少页?注意不要超过 9999 !。输入数字:","9999")
document.Numbering("0000","1",pg,0);
editor.ExecuteCommandByID(3889);  // 垂直选择
document.selection.EndOfLine(false,eeLineView);
document.selection.Text="\x09";
document.Numbering("0001","1",pg,0);
document.selection.Text="\x09";
document.Numbering("0002","1",pg,0);
document.selection.SetActivePoint(eePosLogical, 1, 1);
document.selection.Replace("\\d{5}","0000",eeReplaceAll | eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);
document.selection.Replace("^(\\d{4})\\t(\\d{4})\\t(\\d{4})","</>\\n\\2\\n<a href=\"entry://\\1\">【上一页】</a> 【第\\2页】 <a href=\"entry://\\3\">【下一页】</a><br><img src=\"\\2.png\"><br><a href=\"entry://\\1\">【上一页】</a> 【第\\2页】 <a href=\"entry://\\3\">【下一页】</a><br>",eeReplaceAll | eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);

// 跳转文档开头 ctrl+home--------删去 分隔标志</>
document.selection.StartOfDocument(false);
document.selection.Replace("</>\\n","",eeFindReplaceOnlyWord | eeFindReplaceRegExp,eeExFindRegexOnigmo);
// 跳转文档末尾 ctrl+end--------添加 分隔标志</>
document.selection.EndOfDocument(false);
document.selection.Text="</>";
document.selection.NewLine(1);

3,合并两部分
就可以用MdxBuilder等工具
4,注意问题
1,图片格式为PNG,如果不是,需要修改或者替换。文件名纯数字,4位数。如果数字前面有前缀,如A、P,可以在生成后,进行一次替换。
2,第0001页,【上一页】和最后一页 【下一页】,链接情况请视实际情况修改。

em.7z (934 字节)

5 个赞