Addresses issue #621 (#1181)

* issue#621: html highlighter

* docs for issue#621

* removing windows support for issue#621

Co-authored-by: Tinmarino <tinmarino@gmail.com>
This commit is contained in:
ysftaha
2021-12-18 09:40:17 -05:00
committed by GitHub
parent 064a8f7ade
commit 2141fde8b8
3 changed files with 64 additions and 0 deletions
+26
View File
@@ -1879,6 +1879,32 @@ function! s:convert_file(path_html, wikifile) abort
return ''
endif
call vimwiki#path#mkdir(path_html)
if g:vimwiki_global_vars['listing_hl'] > 0 && has("unix")
let i = 0
while i < len(html_lines)
if html_lines[i] =~ '^<pre .*type=.\+>'
let type = split(split(split(html_lines[i], 'type=')[1], '>')[0], '\s\+')[0]
let attr = split(split(html_lines[i], '<pre ')[0], '>')[0]
let start = i + 1
let cur = start
while html_lines[cur] !~ '^<\/pre>'
let cur += 1
endwhile
let tmp = ('tmp'. split(system('mktemp -p . --suffix=.' . type, 'silent'), 'tmp')[-1])[:-2]
call system('echo ' . shellescape(join(html_lines[start:cur - 1], '\n')) . ' > ' . tmp)
call system(g:vimwiki_global_vars['listing_hl_command'] . ' ' . tmp . ' > ' . tmp . '.html')
let html_out = system('cat ' . tmp . '.html')
call system('rm ' . tmp . ' ' . tmp . '.html')
let i = cur
let html_lines = html_lines[0:start - 1] + split(html_out, '\n') + html_lines[cur:]
endif
let i += 1
endwhile
endif
call writefile(html_lines, path_html.htmlfile)
return path_html . htmlfile
endif