Skip to content

Commit 9cb4342

Browse files
committed
Import the latest scripts from vim-jp/vimdoc-ja-working
1 parent 2b6f637 commit 9cb4342

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ html:
88
if [ ! -d vim/runtime/doc ]; then git clone --depth=1 https://github.com/vim/vim.git; fi
99
if [ ! -d vim_faq/doc ]; then git clone --depth=1 https://github.com/chrisbra/vim_faq.git; fi
1010
cd vim; git apply ../tools/add-vimfaq-link.diff; cd ..
11-
cp vim/runtime/doc/*.txt target/html/doc
12-
cp vim_faq/doc/*.txt target/html/doc
13-
cp tools/buildhtml.vim tools/makehtml.vim target/html
14-
-cd target/html/doc ; vim --cmd "set rtp^=../../../tools" -eu ../buildhtml.vim -c "qall!"
11+
cp vim/runtime/doc/*.txt vim_faq/doc/*.txt target/html/doc
12+
-cd target/html/doc ; vim -eu ../../../tools/buildhtml.vim -c "qall!"
1513

1614
clean:
1715
rm -rf target

tools/buildhtml.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ let g:html_no_progress = 1
88

99
enew!
1010

11+
source <sfile>:h/tag_aliases.vim
12+
source <sfile>:h/untranslated.vim
1113
source <sfile>:h/makehtml.vim
1214

15+
let s:tools_dir = expand('<sfile>:p:h')
16+
let s:proj_dir = expand('<sfile>:p:h:h')
17+
1318
function! s:main()
19+
" for the lastest help syntax
20+
let &runtimepath = s:tools_dir . ',' . &runtimepath
1421
" for ja custom syntax
15-
let &runtimepath .= ',' . expand('<sfile>:p:h')
22+
let &runtimepath .= ',' . s:proj_dir
1623
call s:BuildHtml()
1724
endfunction
1825

tools/makehtml.vim

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@
1212
" Usage:
1313
" :cd doc
1414
" :helptags .
15-
" :source mkhtml.vim
15+
" :source makehtml.vim
1616
" :call MakeHtmlAll()
1717

18-
function! MakeHtmlAll()
18+
if !exists('g:makehtml_external_taglinks')
19+
let g:makehtml_external_taglinks = {}
20+
end
21+
22+
function! MakeHtmlAll(...)
23+
let conceal = get(a:000, 0, 1) " Enable concealing by default.
1924
let s:log = []
2025
call MakeTagsFile()
2126
echo ""
2227
let files = split(glob('*.??[tx]'), '\n')
2328
for i in range(len(files))
2429
let file = files[i]
2530
echon printf("%d/%d %s -> %s", i+1, len(files), files[i], s:HtmlName(files[i]))
26-
call MakeHtml(file)
31+
call MakeHtml(file, conceal)
2732
echon " *DONE*"
2833
echo ""
2934
endfor
@@ -58,13 +63,13 @@ function! MakeTagsFile()
5863
endfor
5964
endfunction
6065

61-
function! MakeHtml(fname)
62-
let r = MakeHtml2(a:fname, s:HtmlName(a:fname))
66+
function! MakeHtml(fname, conceal)
67+
let r = MakeHtml2(a:fname, s:HtmlName(a:fname), a:conceal)
6368
silent quit!
6469
return r
6570
endfunction
6671

67-
function! MakeHtml2(src, dst)
72+
function! MakeHtml2(src, dst, conceal)
6873
silent new `=a:src`
6974

7075
" 2html options
@@ -83,7 +88,7 @@ function! MakeHtml2(src, dst)
8388
silent! call tohtml#Convert2HTML(1, line('$'))
8489

8590
let lang = s:GetLang(a:src)
86-
silent %s@<span class="\(helpHyperTextEntry\|helpHyperTextJump\|helpOption\|helpCommand\)">\([^<]*\)</span>@\=s:MakeLink(lang, submatch(1), submatch(2))@ge
91+
silent %s@<span class="\(helpHyperTextEntry\|helpHyperTextJump\|helpOption\|helpCommand\)">\([^<]*\)</span>@\=s:MakeLink(lang, submatch(1), submatch(2), a:conceal)@ge
8792
silent %s@^<span class="Ignore">&lt;</span>\ze&nbsp;@\&nbsp;@ge
8893
silent %s@<span class="\(helpStar\|helpBar\|Ignore\)">[^<]*</span>@@ge
8994
call s:TranslateHelpExampleBlock()
@@ -146,21 +151,28 @@ function! s:Footer()
146151
call append(search('^</body', 'wn') - 1, footer)
147152
endfunction
148153

149-
function! s:MakeLink(lang, hlname, tagname)
154+
function! s:MakeLink(lang, hlname, tagname, conceal)
150155
let tagname = a:tagname
151156
let tagname = substitute(tagname, '&lt;', '<', 'g')
152157
let tagname = substitute(tagname, '&gt;', '>', 'g')
153158
let tagname = substitute(tagname, '&amp;', '\&', 'g')
154-
if a:hlname == "helpHyperTextEntry"
155-
let sep = "*"
156-
elseif a:hlname == "helpHyperTextJump"
157-
let sep = "|"
158-
elseif a:hlname == "helpCommand"
159-
let sep = "`"
160-
elseif a:hlname == "helpOption"
159+
if a:conceal
161160
let sep = ""
161+
else
162+
if a:hlname == "helpHyperTextEntry"
163+
let sep = "*"
164+
elseif a:hlname == "helpHyperTextJump"
165+
let sep = "|"
166+
elseif a:hlname == "helpCommand"
167+
let sep = "`"
168+
elseif a:hlname == "helpOption"
169+
let sep = ""
170+
endif
162171
endif
163172
let tags = s:GetTags(a:lang)
173+
if !has_key(tags, tagname) && has_key(g:makehtml_tag_aliases, tagname)
174+
let tagname = g:makehtml_tag_aliases[tagname]
175+
endif
164176
if has_key(tags, tagname)
165177
let href = tags[tagname]["html"]
166178
if tagname !~ '\.txt$' && tagname != "help-tags"
@@ -192,6 +204,9 @@ function! s:MakeLink(lang, hlname, tagname)
192204
elseif a:hlname == "helpCommand"
193205
" Don't use MissingTag class for a command.
194206
let res = printf('<span class="%s">%s%s%s</span>', s:attr_save[a:hlname], sep, a:tagname, sep)
207+
elseif has_key(g:makehtml_external_taglinks, a:tagname)
208+
let url = g:makehtml_external_taglinks[a:tagname]
209+
let res = printf('<a class="ExternalTaglink" href="%s">%s%s%s</a>', url, sep, a:tagname, sep)
195210
else
196211
let res = printf('<span class="MissingTag">%s%s%s</span>', sep, a:tagname, sep)
197212
endif

tools/tag_aliases.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let g:makehtml_tag_aliases = {
2+
\ '=~': 'expr-=~',
3+
\ }

tools/untranslated.vim

Whitespace-only changes.

0 commit comments

Comments
 (0)