diff --git a/MdxSourceBuilder.vim b/MdxSourceBuilder.vim index 96112bb..1c93dee 100644 --- a/MdxSourceBuilder.vim +++ b/MdxSourceBuilder.vim @@ -33,10 +33,11 @@ let g:pageNumDigit = 4 " \[dictionaryPart, picNamePrefix, picFormat, " \sourceStyle, navStyle, locationPercent, nearestKeyword], let g:dictionaryParts = [ - \["火星词典.Cover.txt", "MarsDictCover_", ".png", 0, 1, 0, 1], - \["火星词典.Prefix.txt", "MarsDictPrefix_", ".png", 0, 1, 0, 1], + \["火星词典.Cover.txt", "MarsDictCover_", ".png", 0, 2, 0, 1], + \["火星词典.Prefix.txt", "MarsDictPrefix_", ".png", 0, 2, 0, 1], \["火星词典.Body.Part1.txt", "MarsDict_", ".png", 0, 2, 1, 1], \["火星词典.Body.Part2.txt", "MarsDict_", ".png", 1, 2, 1, 1], + \["火星词典.Body.Part3.txt", "MarsDict_", ".png", 3, 2, 1, 1], \["火星词典.Appendix.txt", "MarsDictAppendix_", ".png", 0, 1, 0, 1], \["火星词典.Pinyin.txt", "MarsDict_", ".png", 2, 0, 0, 0], \] @@ -47,6 +48,7 @@ let g:dictionaryParts = [ " - 0:'一行页码 + 多行关键词(每行一个关键词)'的标准词条格式,跳转至页码 " - 1:'一个页码 + 多个中文单字符的关键词'的压缩词条格式,跳转至页码 " - 2:'页码 + 分隔符 + 单个中或英关键词'的啰嗦行格式,跳转至页码 +" - 3:'单个中或英关键词 + 分隔符 + 页码'的啰嗦行格式,跳转至页码 " navStyle:定义个性化的词条导航样式(MdxSourceBuilderCore.Vim) " - 0:自身没有页面和keywords导航,仅转LINK,适用于拼音之类的辅助检索 " - 1:仅有页面导航,无keywords导航,简洁,适用于封面/附录之类的Affix @@ -62,13 +64,13 @@ let g:dictionaryParts = [ let s:anyMore = 1 " 格式:\[anyMorePart, sourceStyle, pagePrefix], let g:anyMoreSources = [ - \["火星词典.Link1.txt", 4, ""], - \["火星词典.Link2.txt", 5, "OPEU3_"], + \["火星词典.Link1.txt", 104, ""], + \["火星词典.Link2.txt", 105, "MarsDict_"], \["火星词典.Link3.txt", 998, ""], - \["火星词典.Link4.txt", 7, ""], - \["火星词典.Link5.txt", 6, "OPEU3Pre_"], + \["火星词典.Link4.txt", 107, ""], + \["火星词典.Link5.txt", 106, "MarsDictPrefix_"], \["火星词典.Link6.txt", 998, ""], - \["火星词典.Link7.txt", 0, "OPEU3_"], + \["火星词典.Link7.txt", 0, "MarsDict_"], \["火星词典.Link888.txt", 888, ""], \] " anyMorePart:源文件的名称,包括后缀名 @@ -76,11 +78,12 @@ let g:anyMoreSources = [ " - 0:固定项目,'一行页码 + 多行关键词(每行一个关键词)'的标准词条格式 " - 1:固定项目,'一个页码 + 多个中文单字符的关键词'的压缩词条格式 " - 2:固定项目,'页码 + 分隔符 + 单个中或英关键词'的啰嗦行格式 +" - 3:固定项目,'单个中或英关键词 + 分隔符 + 页码'的啰嗦行格式 " - 888: 固定项目,用于快速手工添加链接词条,"现有关键词\t链接词条" " - 998: 固定项目,源文件为标准的mdx源格式,但欠缺CSS文件等必要元素 " - 999:固定项目,源文件为标准的mdx源格式,无需进一步处理,直接使用 -" - 其他: 定制化项目,自定义词条样式及处理程序 -" pagePrefix:可选;但当sourceStyle为0/1/2时,必须配置 +" - 其他: 定制化项目,自定义词条样式及处理程序,建议用101-199以示区别 +" pagePrefix:按需可选;但当sourceStyle为0/1/2/3时,必须配置 " 自定义固定链接的导航:\[链接名称, 链接目标], let g:customNavList = [ diff --git a/MdxSourceBuilderCSS.vim b/MdxSourceBuilderCSS.vim index a2fc06a..2c18c32 100644 --- a/MdxSourceBuilderCSS.vim +++ b/MdxSourceBuilderCSS.vim @@ -93,4 +93,6 @@ color: red!important; } +/* 更多自定义CSS */ + /* vim: set et sw=4 ts=4 sts=4 fdm=marker ff=unix ft=css fenc=utf8 nobomb: */ diff --git a/MdxSourceBuilderCore.vim b/MdxSourceBuilderCore.vim index 4545baa..9d3eb3a 100644 --- a/MdxSourceBuilderCore.vim +++ b/MdxSourceBuilderCore.vim @@ -46,9 +46,33 @@ function! StandardizeStyle(sourceStyle) " 0002 abandonee " 0002 a bas " 0003 abdominous + " 将所有Tab替换为空格 + silent! set expandtab tabstop=4 | %retab normal gg + let linenumber = printf(s:pageNumDigit, 0) + for line in getline(1,'$') + let words = split(line, '\s\{4,}') + if linenumber == words[0] + silent! s/^.*$/\= words[1]/e + else + let linenumber = words[0] + silent! s/^.*$/\= words[0] . "\n". get(words, 1, "")/e + endif + silent! normal j + endfor + elseif s:sourceStyle == 3 + " 适合如下词条格式:行格式为"单个中或英关键词 + 分隔符 + 页码" + " 分隔符兼容:Tab键'\t', 4个及以上空格'\s\{4,}' + " abandon 0001 + " abandoned 0001 + " abandonee 0002 + " a bas 0002 + " abdominous 0003 " 将所有Tab替换为空格 silent! set expandtab tabstop=4 | %retab + " 将格式转为sourceStyle 2 + silent! %s/^\(.\{-}\)\s\{4,}\(\d\{3,}\)$/\2 \1/ + normal gg let linenumber = printf(s:pageNumDigit, 0) for line in getline(1,'$') let words = split(line, '\s\{4,}') @@ -61,7 +85,7 @@ function! StandardizeStyle(sourceStyle) silent! normal j endfor else - " echomsg "未定义处理方案" + echomsg "警告!未定义 SourceStyle " . a:sourceStyle . " 的标准化方案!" endif " 清理并保存,以便后续代码可以正常运作 silent! normal! Go @@ -304,7 +328,7 @@ function! KeywordsNav(currentPage, currentWord) endfunction " 根据sourceStyle和NavStyle输出标准的mdx源文件格式 ---------------------------------{{{1 -if s:sourceStyle == 0 || s:sourceStyle == 1 || s:sourceStyle == 2 +if index([0,1,2,3], s:sourceStyle) >= 0 " 运行初始化函数 silent! call StandardizeStyle(s:sourceStyle) silent! call PageList() diff --git a/MdxSourceBuilderLink.vim b/MdxSourceBuilderLink.vim index dbf47d3..ee3c79e 100644 --- a/MdxSourceBuilderLink.vim +++ b/MdxSourceBuilderLink.vim @@ -41,9 +41,33 @@ function! StandardizeStyle(sourceStyle) " 0002 abandonee " 0002 a bas " 0003 abdominous + " 将所有Tab替换为空格 + silent! set expandtab tabstop=4 | %retab normal gg + let linenumber = printf(s:pageNumDigit, 0) + for line in getline(1,'$') + let words = split(line, '\s\{4,}') + if linenumber == words[0] + silent! s/^.*$/\= words[1]/e + else + let linenumber = words[0] + silent! s/^.*$/\= words[0] . "\n". get(words, 1, "")/e + endif + silent! normal j + endfor + elseif s:sourceStyle == 3 + " 适合如下词条格式:行格式为"单个中或英关键词 + 分隔符 + 页码" + " 分隔符兼容:Tab键'\t', 4个及以上空格'\s\{4,}' + " abandon 0001 + " abandoned 0001 + " abandonee 0002 + " a bas 0002 + " abdominous 0003 " 将所有Tab替换为空格 silent! set expandtab tabstop=4 | %retab + " 将格式转为sourceStyle 2 + silent! %s/^\(.\{-}\)\s\{4,}\(\d\{3,}\)$/\2 \1/ + normal gg let linenumber = printf(s:pageNumDigit, 0) for line in getline(1,'$') let words = split(line, '\s\{4,}') @@ -56,7 +80,7 @@ function! StandardizeStyle(sourceStyle) silent! normal j endfor else - echomsg "警告!!未定义 SourceStyle " . a:sourceStyle . " 的标准化方案!" + echomsg "警告!未定义 SourceStyle " . a:sourceStyle . " 的标准化方案!" endif " 清理并保存,以便后续代码可以正常运作 silent! normal! Go @@ -108,7 +132,7 @@ function! KeywordsDicts() endfunction " 根据SourceStyle输出标准的mdx源文件格式 ----------------------------------{{{1 -if s:sourceStyle == 0 || s:sourceStyle == 1 || s:sourceStyle == 2 +if index([0,1,2,3], s:sourceStyle) >= 0 " 运行初始化函数 silent! call StandardizeStyle(s:sourceStyle) silent! call PageList() @@ -125,11 +149,10 @@ if s:sourceStyle == 0 || s:sourceStyle == 1 || s:sourceStyle == 2 silent! $put k endfor endfor -elseif s:sourceStyle == 3 -elseif s:sourceStyle == 4 +elseif s:sourceStyle == 104 " 将带有编号的主词条改造为使用"s+编号"进行检索 silent! %s/^\(\d*\)\(\s.*\)$/s\1\r@@@LINK=\0\r<\/>/ -elseif s:sourceStyle == 5 +elseif s:sourceStyle == 105 " 运行初始化函数 silent! call StandardizeStyle(s:sourceStyle) silent! call PageList() @@ -150,7 +173,7 @@ elseif s:sourceStyle == 5 silent! $put k endfor endfor -elseif s:sourceStyle == 6 +elseif s:sourceStyle == 106 " 1. “中英文”定位到页面 let lineDicts = {} let lineNumber = 0 @@ -179,7 +202,7 @@ elseif s:sourceStyle == 6 \. '' silent! $put k endfor -elseif s:sourceStyle == 7 +elseif s:sourceStyle == 107 " 添加编号链接 silent! %s/\(\d\+\)/\1<\/a>/g " 给每个词条添加CSS diff --git a/exchange.vim b/exchange.vim new file mode 100644 index 0000000..f673685 --- /dev/null +++ b/exchange.vim @@ -0,0 +1,15 @@ +silent! set expandtab tabstop=4 | %retab +" 将格式转为sourceStyle 2 +silent! %s/^\(.\{-}\)\s\{4,}\(\d\{3,}\)$/\2 \1/ +normal gg +let linenumber = printf('%04d', 0) +for line in getline(1,'$') + let words = split(line, '\s\{4,}') + if linenumber == words[0] + silent! s/^.*$/\= words[1]/e + else + let linenumber = words[0] + silent! s/^.*$/\= words[0] . "\n". get(words, 1, "")/e + endif + silent! normal j +endfor diff --git "a/\347\201\253\346\230\237\350\257\215\345\205\270.Body.Part3.txt" "b/\347\201\253\346\230\237\350\257\215\345\205\270.Body.Part3.txt" new file mode 100644 index 0000000..5613256 --- /dev/null +++ "b/\347\201\253\346\230\237\350\257\215\345\205\270.Body.Part3.txt" @@ -0,0 +1,23 @@ +这是keyword 0301 +key word 可以有空格 0302 +分隔符最好用4位及以上的空格 0303 +虽可以使用tab但与vim配置有关 0303 +尽量不用tab 避免兼容性 0399 +0399 +0399 +同一页码可以出现多次 0399 +0304 +0305 +可以只有页码 0306 +0311 +0312 +也可以跳页码 0318 +跳过页码的将不会出现在导航条上 0330 +可以用于跳过不想要的页面 0330 +页码可以乱序 0302 +但你很难找出哪些页面遗漏了 0355 +相比之下不如SourceStyle2 0323 +排列整齐 0358 +排查容易 0365 +但Style3肯定是支持的 0358 +请放心使用 0366 diff --git "a/\347\201\253\346\230\237\350\257\215\345\205\270.info.description.html" "b/\347\201\253\346\230\237\350\257\215\345\205\270.info.description.html" index 5b41346..e4a9ff6 100644 --- "a/\347\201\253\346\230\237\350\257\215\345\205\270.info.description.html" +++ "b/\347\201\253\346\230\237\350\257\215\345\205\270.info.description.html" @@ -1,6 +1,6 @@ -

火星词典

-
-

这是看懂火星语必备的词典

-

blabla

-
-

Mdx created by VimVim 2020/08/12

+

火星词典

+
+

这是看懂火星语必备的词典

+

blabla

+
+

Mdx created by VimVim 2020/08/12

diff --git "a/\347\201\253\346\230\237\350\257\215\345\205\270.info.title.html" "b/\347\201\253\346\230\237\350\257\215\345\205\270.info.title.html" index 6735bfc..73880f4 100644 --- "a/\347\201\253\346\230\237\350\257\215\345\205\270.info.title.html" +++ "b/\347\201\253\346\230\237\350\257\215\345\205\270.info.title.html" @@ -1 +1 @@ -火星词典 37th +火星词典 37th