From 348f72524dc205baffa994e498a033b66a082ce0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 24 Apr 2021 16:52:46 -0400 Subject: vim-patch:0c0734d527a1 Update runtime files https://github.com/vim/vim/commit/0c0734d527a132edfb4089be48486586424b3f41 Omit rand(), srand() documentation. Patch v8.1.2342 is not ported yet. --- runtime/syntax/2html.vim | 551 +++++++++++++++++++++++++++++------------------ 1 file changed, 336 insertions(+), 215 deletions(-) (limited to 'runtime/syntax/2html.vim') diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim index 91bb0e0d4a..854059ba86 100644 --- a/runtime/syntax/2html.vim +++ b/runtime/syntax/2html.vim @@ -1,6 +1,6 @@ " Vim syntax support file " Maintainer: Ben Fritz -" Last Change: 2018 Nov 11 +" Last Change: 2019 Nov 13 " " Additional contributors: " @@ -20,8 +20,13 @@ " this file uses line continuations let s:cpo_sav = &cpo let s:ls = &ls +let s:ei_sav = &eventignore set cpo&vim +" HTML filetype can take a while to load/highlight if the destination file +" already exists. +set eventignore+=FileType + let s:end=line('$') " Font @@ -37,6 +42,14 @@ endif let s:settings = tohtml#GetUserSettings() +if s:settings.use_xhtml + let s:html5 = 0 +elseif s:settings.use_css && !s:settings.no_pre + let s:html5 = 1 +else + let s:html5 = 0 +endif + if !exists('s:FOLDED_ID') let s:FOLDED_ID = hlID("Folded") | lockvar s:FOLDED_ID let s:FOLD_C_ID = hlID("FoldColumn") | lockvar s:FOLD_C_ID @@ -69,9 +82,10 @@ if !empty(s:settings.prevent_copy) endif endif -" When not in gui we can only guess the colors. -" TODO - is this true anymore? -if has("gui_running") +" When gui colors are not supported, we can only guess the colors. +" TODO - is this true anymore? Is there a way to ask the terminal what colors +" each number means or read them from some file? +if &termguicolors || has("gui_running") let s:whatterm = "gui" else let s:whatterm = "cterm" @@ -352,6 +366,12 @@ if s:settings.use_css \ ] else + " New method: use generated content in the CSS. The only thing needed here + " is a span with no content, with an attribute holding the desired text. + " + " Old method: use an element when text is unsectable. This is still + " used in conditional comments for Internet Explorer, where the new method + " doesn't work. " " Wrap the in a to allow fixing the stupid bug in some fonts " which cause browsers to display a 1px gap between lines when these @@ -369,16 +389,26 @@ if s:settings.use_css " to use strchars(), because HTML specifies that the maxlength parameter " uses the number of unique codepoints for its limit. let wrapperfunc_lines += [ - \ ' if a:make_unselectable', - \ ' return "'. - \ '"', + \ ' if a:make_unselectable', + \ ' return "' + endif + let wrapperfunc_lines[-1] .= '"' + let wrapperfunc_lines += [ \ ' else', \ ' return "".a:text.""' \ ] @@ -501,27 +531,63 @@ else endfun endif if s:settings.prevent_copy =~# 'f' - " Note the elements for fill spaces will have a single space for - " content, to allow active cursor CSS selection to work. - " - " Wrap the whole thing in a span for the 1px padding workaround for gaps. - function! s:FoldColumn_build(char, len, numfill, char2, class, click) - let l:input_open = "" : "'>") - return "". - \ l:input_open.l:common_attrs.repeat(a:char, a:len). - \ (!empty(a:char2) ? a:char2 : ""). - \ l:input_close . "" - endfun - function! s:FoldColumn_fill() - return s:FoldColumn_build('', s:foldcolumn, 0, '', 'FoldColumn', '') - endfun + if s:settings.use_input_for_pc ==# 'none' + " Simply space-pad to the desired width inside the generated content (note + " that the FoldColumn definition includes a whitespace:pre rule) + function! s:FoldColumn_build(char, len, numfill, char2, class, click) + return "" + endfun + function! s:FoldColumn_fill() + return s:HtmlFormat(repeat(' ', s:foldcolumn), s:FOLD_C_ID, 0, "", 1) + endfun + else + " Note the elements for fill spaces will have a single space for + " content, to allow active cursor CSS selection to work. + " + " Wrap the whole thing in a span for the 1px padding workaround for gaps. + " + " Build the function line by line containing only what is needed for the + " options in use for maximum code sharing with minimal branch logic for + " greater speed. + " + " Note, 'exec' commands do not recognize line continuations, so must + " concatenate lines rather than continue them. + let build_fun_lines = [ + \ 'function! s:FoldColumn_build(char, len, numfill, char2, class, click)', + \ ' let l:input_open = "" : "''>")' + \ ] + if s:settings.use_input_for_pc ==# 'fallback' + let build_fun_lines += [ + \ ' let l:gen_content_link ='. + \ ' ""' + \ ] + endif + let build_fun_lines += [ + \ ' return "".'. + \ ' l:input_open.l:common_attrs.repeat(a:char, a:len).(a:char2).'. + \ ' l:input_close.'. + \ (s:settings.use_input_for_pc ==# 'fallback' ? 'l:gen_content_link.' : ""). + \ ' ""', + \ 'endfun' + \ ] + " create the function we built line by line above + exec join(build_fun_lines, "\n") + + function! s:FoldColumn_fill() + return s:FoldColumn_build(' ', s:foldcolumn, 0, '', 'FoldColumn', '') + endfun + endif else " For normal fold columns, simply space-pad to the desired width (note that " the FoldColumn definition includes a whitespace:pre rule) @@ -755,7 +821,11 @@ call extend(s:lines, [ " include encoding as close to the top as possible, but only if not already " contained in XML information (to avoid haggling over content type) if s:settings.encoding != "" && !s:settings.use_xhtml - call add(s:lines, "".expand("%:p:~").""), @@ -766,6 +836,7 @@ call add(s:lines, '", + \ s:settings.use_xhtml ? "" : "', - \ '']) - " TODO: IE7 doesn't *actually* support XHTML, maybe we should remove this. - " But if it's served up as tag soup, maybe the following will work, so - " leave it in for now. - call extend(s:lines, [ + \ ".closed-fold:hover > .Folded { display: none; }"]) + " TODO: IE6 is REALLY old and I can't even test it anymore. Maybe we + " should remove this? Leave it in for now, it was working at one point, + " and doesn't affect any modern browsers. Even newer IE versions should + " support the above code and ignore the following. + let s:ieonly = [ \ "", - \]) + \] else " if we aren't doing hover_unfold, use CSS 1 only call extend(s:lines, [ - \ "' \]) endif - else - " if we aren't doing any dynamic folding, no need for any special rules - call extend(s:lines, [ - \ "", \]) - endif + call extend(s:lines, s:ieonly) + unlet s:ieonly endif -let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy) +let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids " insert script tag if needed if s:uses_script call extend(s:lines, [ \ "", - \ "