-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathbuild_html.vim
68 lines (55 loc) · 1.28 KB
/
build_html.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
set nocompatible
set nomore
set encoding=utf-8
set fileencodings=utf-8
syntax on
colorscheme delek
let g:html_no_progress = 1
if has('windows') && !has('gui_running')
set t_ti=
endif
enew!
source <sfile>:h/tag_aliases.vim
source <sfile>:h/untranslated.vim
source <sfile>:h/makehtml.vim
let s:tools_dir = expand('<sfile>:p:h')
let s:proj_dir = expand('<sfile>:p:h:h')
function! s:main()
" for the lastest help syntax
let &runtimepath = s:tools_dir . ',' . &runtimepath
" for ja custom syntax
let &runtimepath .= ',' . s:proj_dir
if argc() != 2
echoerr "require two arguments"
finish
endif
call s:BuildHtml(argv(0), argv(1))
endfunction
function! s:BuildHtml(src, dst)
call MakeHtml2(a:src, a:dst, 1)
call s:ToJekyll(a:dst)
endfunction
function! s:ToJekyll(file)
set nomodeline
execute "edit! " . a:file
set fileformat=unix
let helpname = expand('%:t:r')
if helpname == 'index'
let helpname = 'help'
endif
" remove header
silent 1,/^<hr>/delete _
" remove footer
silent /^<hr>/,$delete _
" escape jekyll tags
silent %s/{\{2,}\|{%/{{ "\0" }}/ge
" YAML front matter
call append(0, [
\ '---',
\ 'layout: vimdoc',
\ printf("helpname: '%s'", helpname),
\ '---',
\ ])
update!
endfunction
call s:main()