Created
August 29, 2013 10:41
-
-
Save blindFS/6376599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:process_tag_pre_pygments(line, pre) "{{{ | |
if !executable('pygmentize') | |
return s:process_tag_pre(a:line, a:pre) | |
endif | |
let lines = [] | |
let pre = a:pre | |
let processed = 0 | |
if !pre[0] && a:line =~ '^\s*{{{' | |
let s:syntax = matchstr(a:line, 'class=.\zs\w\+') | |
let s:syntax = s:syntax == "" ? "text" : s:syntax | |
if exists("g:vimwiki_code_syntax_map['".s:syntax."']") | |
let s:syntax = g:vimwiki_code_syntax_map[s:syntax] | |
endif | |
let s:lines_pre = "" | |
let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))] | |
let processed = 1 | |
elseif pre[0] && a:line =~ '^\s*}}}\s*$' | |
let pre = [0, 0] | |
let processed = 1 | |
redir! > ~/tmp/.pretemp | |
silent! echo s:lines_pre | |
redir END | |
silent! execute "!pygmentize -l ".s:syntax." -f html -o ~/tmp/.pretemp.html ~/tmp/.pretemp" | |
let lines = split(system("cat ~/tmp/.pretemp.html"),'\n') | |
silent !rm -f ~/tmp/.pretemp.html | |
elseif pre[0] | |
let processed = 1 | |
let s:lines_pre .= a:line."\n" | |
endif | |
return [processed, lines, pre] | |
endfunction "}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
直接读stdout的话unicode会莫名其妙的出错,只好存文件了,略丑...