comparison runtime/syntax/2html.vim @ 18719:99586852c2db

Update runtime files Commit: https://github.com/vim/vim/commit/0c0734d527a132edfb4089be48486586424b3f41 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 26 21:44:46 2019 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Nov 2019 21:45:05 +0100
parents f8b0f1e42f2c
children 1a951a4beee3
comparison
equal deleted inserted replaced
18718:710efe6952f4 18719:99586852c2db
1 " Vim syntax support file 1 " Vim syntax support file
2 " Maintainer: Ben Fritz <fritzophrenic@gmail.com> 2 " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
3 " Last Change: 2018 Nov 11 3 " Last Change: 2019 Nov 13
4 " 4 "
5 " Additional contributors: 5 " Additional contributors:
6 " 6 "
7 " Original by Bram Moolenaar <Bram@vim.org> 7 " Original by Bram Moolenaar <Bram@vim.org>
8 " Modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz> 8 " Modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>
18 " Transform a file into HTML, using the current syntax highlighting. 18 " Transform a file into HTML, using the current syntax highlighting.
19 19
20 " this file uses line continuations 20 " this file uses line continuations
21 let s:cpo_sav = &cpo 21 let s:cpo_sav = &cpo
22 let s:ls = &ls 22 let s:ls = &ls
23 let s:ei_sav = &eventignore
23 set cpo&vim 24 set cpo&vim
25
26 " HTML filetype can take a while to load/highlight if the destination file
27 " already exists.
28 set eventignore+=FileType
24 29
25 let s:end=line('$') 30 let s:end=line('$')
26 31
27 " Font 32 " Font
28 if exists("g:html_font") 33 if exists("g:html_font")
34 else 39 else
35 let s:htmlfont = "monospace" 40 let s:htmlfont = "monospace"
36 endif 41 endif
37 42
38 let s:settings = tohtml#GetUserSettings() 43 let s:settings = tohtml#GetUserSettings()
44
45 if s:settings.use_xhtml
46 let s:html5 = 0
47 elseif s:settings.use_css && !s:settings.no_pre
48 let s:html5 = 1
49 else
50 let s:html5 = 0
51 endif
39 52
40 if !exists('s:FOLDED_ID') 53 if !exists('s:FOLDED_ID')
41 let s:FOLDED_ID = hlID("Folded") | lockvar s:FOLDED_ID 54 let s:FOLDED_ID = hlID("Folded") | lockvar s:FOLDED_ID
42 let s:FOLD_C_ID = hlID("FoldColumn") | lockvar s:FOLD_C_ID 55 let s:FOLD_C_ID = hlID("FoldColumn") | lockvar s:FOLD_C_ID
43 let s:LINENR_ID = hlID('LineNr') | lockvar s:LINENR_ID 56 let s:LINENR_ID = hlID('LineNr') | lockvar s:LINENR_ID
67 " they cannot be deleted easily by deliberately inserting invalid markup. 80 " they cannot be deleted easily by deliberately inserting invalid markup.
68 let s:unselInputType = " type='invalid_input_type'" 81 let s:unselInputType = " type='invalid_input_type'"
69 endif 82 endif
70 endif 83 endif
71 84
72 " When not in gui we can only guess the colors. 85 " When gui colors are not supported, we can only guess the colors.
73 " TODO - is this true anymore? 86 " TODO - is this true anymore? Is there a way to ask the terminal what colors
74 if has("gui_running") 87 " each number means or read them from some file?
88 if &termguicolors || has("gui_running")
75 let s:whatterm = "gui" 89 let s:whatterm = "gui"
76 else 90 else
77 let s:whatterm = "cterm" 91 let s:whatterm = "cterm"
78 if &t_Co == 8 92 if &t_Co == 8
79 let s:cterm_color = { 93 let s:cterm_color = {
350 let wrapperfunc_lines += [ 364 let wrapperfunc_lines += [
351 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\">".a:text."</span>"' 365 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\">".a:text."</span>"'
352 \ ] 366 \ ]
353 else 367 else
354 368
369 " New method: use generated content in the CSS. The only thing needed here
370 " is a span with no content, with an attribute holding the desired text.
371 "
372 " Old method: use an <input> element when text is unsectable. This is still
373 " used in conditional comments for Internet Explorer, where the new method
374 " doesn't work.
355 " 375 "
356 " Wrap the <input> in a <span> to allow fixing the stupid bug in some fonts 376 " Wrap the <input> in a <span> to allow fixing the stupid bug in some fonts
357 " which cause browsers to display a 1px gap between lines when these 377 " which cause browsers to display a 1px gap between lines when these
358 " <input>s have a background color (maybe not really a bug, this isn't 378 " <input>s have a background color (maybe not really a bug, this isn't
359 " well-defined) 379 " well-defined)
367 " 387 "
368 " Note, if maxlength property needs to be added in the future, it will need 388 " Note, if maxlength property needs to be added in the future, it will need
369 " to use strchars(), because HTML specifies that the maxlength parameter 389 " to use strchars(), because HTML specifies that the maxlength parameter
370 " uses the number of unique codepoints for its limit. 390 " uses the number of unique codepoints for its limit.
371 let wrapperfunc_lines += [ 391 let wrapperfunc_lines += [
372 \ ' if a:make_unselectable', 392 \ ' if a:make_unselectable',
373 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\">'. 393 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\"'
374 \ '<input'.s:unselInputType.' class=\"" . l:style_name .'.diffstyle.'"\"'. 394 \ ]
375 \ ' value=\"".substitute(a:unformatted,''\s\+$'',"","")."\"'. 395 if s:settings.use_input_for_pc !=# 'all'
376 \ ' onselect=''this.blur(); return false;'''. 396 let wrapperfunc_lines[-1] .= ' " . "data-" . l:style_name . "-content=\"".a:text."\"'
377 \ ' onmousedown=''this.blur(); return false;'''. 397 endif
378 \ ' onclick=''this.blur(); return false;'''. 398 let wrapperfunc_lines[-1] .= '>'
379 \ ' readonly=''readonly'''. 399 if s:settings.use_input_for_pc !=# 'none'
380 \ ' size=\"".strwidth(a:unformatted)."\"'. 400 let wrapperfunc_lines[-1] .=
381 \ (s:settings.use_xhtml ? '/' : '').'></span>"', 401 \ '<input'.s:unselInputType.' class=\"" . l:style_name .'.diffstyle.'"\"'.
402 \ ' value=\"".substitute(a:unformatted,''\s\+$'',"","")."\"'.
403 \ ' onselect=''this.blur(); return false;'''.
404 \ ' onmousedown=''this.blur(); return false;'''.
405 \ ' onclick=''this.blur(); return false;'''.
406 \ ' readonly=''readonly'''.
407 \ ' size=\"".strwidth(a:unformatted)."\"'.
408 \ (s:settings.use_xhtml ? '/' : '').'>'
409 endif
410 let wrapperfunc_lines[-1] .= '</span>"'
411 let wrapperfunc_lines += [
382 \ ' else', 412 \ ' else',
383 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'. diffstyle .'"\">".a:text."</span>"' 413 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'. diffstyle .'"\">".a:text."</span>"'
384 \ ] 414 \ ]
385 endif 415 endif
386 let wrapperfunc_lines += [ 416 let wrapperfunc_lines += [
499 function! s:HtmlFormat_d(text, style_id, diff_style_id) 529 function! s:HtmlFormat_d(text, style_id, diff_style_id)
500 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0) 530 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0)
501 endfun 531 endfun
502 endif 532 endif
503 if s:settings.prevent_copy =~# 'f' 533 if s:settings.prevent_copy =~# 'f'
504 " Note the <input> elements for fill spaces will have a single space for 534 if s:settings.use_input_for_pc ==# 'none'
505 " content, to allow active cursor CSS selection to work. 535 " Simply space-pad to the desired width inside the generated content (note
506 " 536 " that the FoldColumn definition includes a whitespace:pre rule)
507 " Wrap the whole thing in a span for the 1px padding workaround for gaps. 537 function! s:FoldColumn_build(char, len, numfill, char2, class, click)
508 function! s:FoldColumn_build(char, len, numfill, char2, class, click) 538 return "<a href='#' class='".a:class."' onclick='".a:click."' data-FoldColumn-content='".
509 let l:input_open = "<input readonly='readonly'".s:unselInputType. 539 \ repeat(a:char, a:len).a:char2.repeat(' ', a:numfill).
510 \ " onselect='this.blur(); return false;'". 540 \ "'></a>"
511 \ " onmousedown='this.blur(); ".a:click." return false;'". 541 endfun
512 \ " onclick='return false;' size='". 542 function! s:FoldColumn_fill()
513 \ string(a:len + (empty(a:char2) ? 0 : 1) + a:numfill) . 543 return s:HtmlFormat(repeat(' ', s:foldcolumn), s:FOLD_C_ID, 0, "", 1)
514 \ "' " 544 endfun
515 let l:common_attrs = "class='FoldColumn' value='" 545 else
516 let l:input_close = (s:settings.use_xhtml ? "' />" : "'>") 546 " Note the <input> elements for fill spaces will have a single space for
517 return "<span class='".a:class."'>". 547 " content, to allow active cursor CSS selection to work.
518 \ l:input_open.l:common_attrs.repeat(a:char, a:len). 548 "
519 \ (!empty(a:char2) ? a:char2 : ""). 549 " Wrap the whole thing in a span for the 1px padding workaround for gaps.
520 \ l:input_close . "</span>" 550 "
521 endfun 551 " Build the function line by line containing only what is needed for the
522 function! s:FoldColumn_fill() 552 " options in use for maximum code sharing with minimal branch logic for
523 return s:FoldColumn_build('', s:foldcolumn, 0, '', 'FoldColumn', '') 553 " greater speed.
524 endfun 554 "
555 " Note, 'exec' commands do not recognize line continuations, so must
556 " concatenate lines rather than continue them.
557 let build_fun_lines = [
558 \ 'function! s:FoldColumn_build(char, len, numfill, char2, class, click)',
559 \ ' let l:input_open = "<input readonly=''readonly''".s:unselInputType.'.
560 \ ' " onselect=''this.blur(); return false;''".'.
561 \ ' " onmousedown=''this.blur(); ".a:click." return false;''".'.
562 \ ' " onclick=''return false;'' size=''".'.
563 \ ' string(a:len + (empty(a:char2) ? 0 : 1) + a:numfill) .'.
564 \ ' "'' "',
565 \ ' let l:common_attrs = "class=''FoldColumn'' value=''"',
566 \ ' let l:input_close = (s:settings.use_xhtml ? "'' />" : "''>")'
567 \ ]
568 if s:settings.use_input_for_pc ==# 'fallback'
569 let build_fun_lines += [
570 \ ' let l:gen_content_link ='.
571 \ ' "<a href=''#'' class=''FoldColumn'' onclick=''".a:click."'' data-FoldColumn-content=''".'.
572 \ ' repeat(a:char, a:len).a:char2.repeat('' '', a:numfill).'.
573 \ ' "''></a>"'
574 \ ]
575 endif
576 let build_fun_lines += [
577 \ ' return "<span class=''".a:class."''>".'.
578 \ ' l:input_open.l:common_attrs.repeat(a:char, a:len).(a:char2).'.
579 \ ' l:input_close.'.
580 \ (s:settings.use_input_for_pc ==# 'fallback' ? 'l:gen_content_link.' : "").
581 \ ' "</span>"',
582 \ 'endfun'
583 \ ]
584 " create the function we built line by line above
585 exec join(build_fun_lines, "\n")
586
587 function! s:FoldColumn_fill()
588 return s:FoldColumn_build(' ', s:foldcolumn, 0, '', 'FoldColumn', '')
589 endfun
590 endif
525 else 591 else
526 " For normal fold columns, simply space-pad to the desired width (note that 592 " For normal fold columns, simply space-pad to the desired width (note that
527 " the FoldColumn definition includes a whitespace:pre rule) 593 " the FoldColumn definition includes a whitespace:pre rule)
528 function! s:FoldColumn_build(char, len, numfill, char2, class, click) 594 function! s:FoldColumn_build(char, len, numfill, char2, class, click)
529 return "<a href='#' class='".a:class."' onclick='".a:click."'>". 595 return "<a href='#' class='".a:class."' onclick='".a:click."'>".
753 \ "<html>", 819 \ "<html>",
754 \ "<head>"]) 820 \ "<head>"])
755 " include encoding as close to the top as possible, but only if not already 821 " include encoding as close to the top as possible, but only if not already
756 " contained in XML information (to avoid haggling over content type) 822 " contained in XML information (to avoid haggling over content type)
757 if s:settings.encoding != "" && !s:settings.use_xhtml 823 if s:settings.encoding != "" && !s:settings.use_xhtml
758 call add(s:lines, "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:settings.encoding . '"' . s:tag_close) 824 if s:html5
825 call add(s:lines, '<meta charset="' . s:settings.encoding . '"' . s:tag_close)
826 else
827 call add(s:lines, "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:settings.encoding . '"' . s:tag_close)
828 endif
759 endif 829 endif
760 call extend(s:lines, [ 830 call extend(s:lines, [
761 \ ("<title>".expand("%:p:~")."</title>"), 831 \ ("<title>".expand("%:p:~")."</title>"),
762 \ ("<meta name=\"Generator\" content=\"Vim/".v:version/100.".".v:version%100.'"'.s:tag_close), 832 \ ("<meta name=\"Generator\" content=\"Vim/".v:version/100.".".v:version%100.'"'.s:tag_close),
763 \ ("<meta name=\"plugin-version\" content=\"".s:pluginversion.'"'.s:tag_close) 833 \ ("<meta name=\"plugin-version\" content=\"".s:pluginversion.'"'.s:tag_close)
764 \ ]) 834 \ ])
765 call add(s:lines, '<meta name="syntax" content="'.s:current_syntax.'"'.s:tag_close) 835 call add(s:lines, '<meta name="syntax" content="'.s:current_syntax.'"'.s:tag_close)
766 call add(s:lines, '<meta name="settings" content="'. 836 call add(s:lines, '<meta name="settings" content="'.
767 \ join(filter(keys(s:settings),'s:settings[v:val]'),','). 837 \ join(filter(keys(s:settings),'s:settings[v:val]'),',').
768 \ ',prevent_copy='.s:settings.prevent_copy. 838 \ ',prevent_copy='.s:settings.prevent_copy.
839 \ ',use_input_for_pc='.s:settings.use_input_for_pc.
769 \ '"'.s:tag_close) 840 \ '"'.s:tag_close)
770 call add(s:lines, '<meta name="colorscheme" content="'. 841 call add(s:lines, '<meta name="colorscheme" content="'.
771 \ (exists('g:colors_name') 842 \ (exists('g:colors_name')
772 \ ? g:colors_name 843 \ ? g:colors_name
773 \ : 'none'). '"'.s:tag_close) 844 \ : 'none'). '"'.s:tag_close)
774 845
775 if s:settings.use_css 846 if s:settings.use_css
847 call extend(s:lines, [
848 \ "<style" . (s:html5 ? "" : " type=\"text/css\"") . ">",
849 \ s:settings.use_xhtml ? "" : "<!--"])
850 let s:ieonly = []
776 if s:settings.dynamic_folds 851 if s:settings.dynamic_folds
777 if s:settings.hover_unfold 852 if s:settings.hover_unfold
778 " if we are doing hover_unfold, use css 2 with css 1 fallback for IE6 853 " if we are doing hover_unfold, use css 2 with css 1 fallback for IE6
779 call extend(s:lines, [ 854 call extend(s:lines, [
780 \ "<style type=\"text/css\">",
781 \ s:settings.use_xhtml ? "" : "<!--",
782 \ ".FoldColumn { text-decoration: none; white-space: pre; }", 855 \ ".FoldColumn { text-decoration: none; white-space: pre; }",
783 \ "", 856 \ "",
784 \ "body * { margin: 0; padding: 0; }", "", 857 \ "body * { margin: 0; padding: 0; }", "",
785 \ ".open-fold > .Folded { display: none; }", 858 \ ".open-fold > span.Folded { display: none; }",
786 \ ".open-fold > .fulltext { display: inline; }", 859 \ ".open-fold > .fulltext { display: inline; }",
787 \ ".closed-fold > .fulltext { display: none; }", 860 \ ".closed-fold > .fulltext { display: none; }",
788 \ ".closed-fold > .Folded { display: inline; }", 861 \ ".closed-fold > span.Folded { display: inline; }",
789 \ "", 862 \ "",
790 \ ".open-fold > .toggle-open { display: none; }", 863 \ ".open-fold > .toggle-open { display: none; }",
791 \ ".open-fold > .toggle-closed { display: inline; }", 864 \ ".open-fold > .toggle-closed { display: inline; }",
792 \ ".closed-fold > .toggle-open { display: inline; }", 865 \ ".closed-fold > .toggle-open { display: inline; }",
793 \ ".closed-fold > .toggle-closed { display: none; }", 866 \ ".closed-fold > .toggle-closed { display: none; }",
794 \ "", "", 867 \ "", "",
795 \ '/* opening a fold while hovering won''t be supported by IE6 and other', 868 \ '/* opening a fold while hovering won''t be supported by IE6 and other',
796 \ "similar browsers, but it should fail gracefully. */", 869 \ "similar browsers, but it should fail gracefully. */",
797 \ ".closed-fold:hover > .fulltext { display: inline; }", 870 \ ".closed-fold:hover > .fulltext { display: inline; }",
798 \ ".closed-fold:hover > .toggle-filler { display: none; }", 871 \ ".closed-fold:hover > .toggle-filler { display: none; }",
799 \ ".closed-fold:hover > .Folded { display: none; }", 872 \ ".closed-fold:hover > .Folded { display: none; }"])
800 \ s:settings.use_xhtml ? "" : '-->', 873 " TODO: IE6 is REALLY old and I can't even test it anymore. Maybe we
801 \ '</style>']) 874 " should remove this? Leave it in for now, it was working at one point,
802 " TODO: IE7 doesn't *actually* support XHTML, maybe we should remove this. 875 " and doesn't affect any modern browsers. Even newer IE versions should
803 " But if it's served up as tag soup, maybe the following will work, so 876 " support the above code and ignore the following.
804 " leave it in for now. 877 let s:ieonly = [
805 call extend(s:lines, [
806 \ "<!--[if lt IE 7]><style type=\"text/css\">", 878 \ "<!--[if lt IE 7]><style type=\"text/css\">",
807 \ ".open-fold .Folded { display: none; }",
808 \ ".open-fold .fulltext { display: inline; }", 879 \ ".open-fold .fulltext { display: inline; }",
880 \ ".open-fold span.Folded { display: none; }",
809 \ ".open-fold .toggle-open { display: none; }", 881 \ ".open-fold .toggle-open { display: none; }",
810 \ ".closed-fold .toggle-closed { display: inline; }", 882 \ ".open-fold .toggle-closed { display: inline; }",
811 \ "", 883 \ "",
812 \ ".closed-fold .fulltext { display: none; }", 884 \ ".closed-fold .fulltext { display: none; }",
813 \ ".closed-fold .Folded { display: inline; }", 885 \ ".closed-fold span.Folded { display: inline; }",
814 \ ".closed-fold .toggle-open { display: inline; }", 886 \ ".closed-fold .toggle-open { display: inline; }",
815 \ ".closed-fold .toggle-closed { display: none; }", 887 \ ".closed-fold .toggle-closed { display: none; }",
816 \ "</style>", 888 \ "</style>",
817 \ "<![endif]-->", 889 \ "<![endif]-->",
818 \]) 890 \]
819 else 891 else
820 " if we aren't doing hover_unfold, use CSS 1 only 892 " if we aren't doing hover_unfold, use CSS 1 only
821 call extend(s:lines, [ 893 call extend(s:lines, [
822 \ "<style type=\"text/css\">",
823 \ s:settings.use_xhtml ? "" :"<!--",
824 \ ".FoldColumn { text-decoration: none; white-space: pre; }", 894 \ ".FoldColumn { text-decoration: none; white-space: pre; }",
825 \ ".open-fold .Folded { display: none; }",
826 \ ".open-fold .fulltext { display: inline; }", 895 \ ".open-fold .fulltext { display: inline; }",
896 \ ".open-fold span.Folded { display: none; }",
827 \ ".open-fold .toggle-open { display: none; }", 897 \ ".open-fold .toggle-open { display: none; }",
828 \ ".closed-fold .toggle-closed { display: inline; }", 898 \ ".open-fold .toggle-closed { display: inline; }",
829 \ "", 899 \ "",
830 \ ".closed-fold .fulltext { display: none; }", 900 \ ".closed-fold .fulltext { display: none; }",
831 \ ".closed-fold .Folded { display: inline; }", 901 \ ".closed-fold span.Folded { display: inline; }",
832 \ ".closed-fold .toggle-open { display: inline; }", 902 \ ".closed-fold .toggle-open { display: inline; }",
833 \ ".closed-fold .toggle-closed { display: none; }", 903 \ ".closed-fold .toggle-closed { display: none; }",
834 \ s:settings.use_xhtml ? "" : '-->',
835 \ '</style>'
836 \]) 904 \])
837 endif 905 endif
838 else 906 endif
839 " if we aren't doing any dynamic folding, no need for any special rules 907 " else we aren't doing any dynamic folding, no need for any special rules
840 call extend(s:lines, [ 908
841 \ "<style type=\"text/css\">", 909 call extend(s:lines, [
842 \ s:settings.use_xhtml ? "" : "<!--",
843 \ s:settings.use_xhtml ? "" : '-->', 910 \ s:settings.use_xhtml ? "" : '-->',
844 \ "</style>", 911 \ "</style>",
845 \]) 912 \])
846 endif 913 call extend(s:lines, s:ieonly)
847 endif 914 unlet s:ieonly
848 915 endif
849 let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy) 916
917 let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids
850 918
851 " insert script tag if needed 919 " insert script tag if needed
852 if s:uses_script 920 if s:uses_script
853 call extend(s:lines, [ 921 call extend(s:lines, [
854 \ "", 922 \ "",
855 \ "<script type='text/javascript'>", 923 \ "<script" . (s:html5 ? "" : " type='text/javascript'") . ">",
856 \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"]) 924 \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
857 endif 925 endif
858 926
859 " insert javascript to toggle folds open and closed 927 " insert javascript to toggle folds open and closed
860 if s:settings.dynamic_folds 928 if s:settings.dynamic_folds
922 \ " window.onhashchange = JumpToLine;", 990 \ " window.onhashchange = JumpToLine;",
923 \ "}" 991 \ "}"
924 \ ]) 992 \ ])
925 endif 993 endif
926 994
927 " Small text columns like the foldcolumn and line number column need a weird
928 " hack to work around Webkit's and (in versions prior to 9) IE's lack of support
929 " for the 'ch' unit without messing up Opera, which also doesn't support it but
930 " works anyway.
931 "
932 " The problem is that without the 'ch' unit, it is not possible to specify a
933 " size of an <input> in terms of character widths. Only Opera seems to do the
934 " "sensible" thing and make the <input> sized to fit exactly as many characters
935 " as specified by its "size" attribute, but the spec actually says "at least
936 " wide enough to fit 'size' characters", so the other browsers are technically
937 " correct as well.
938 "
939 " Anyway, this leads to two diffculties:
940 " 1. The foldcolumn is made up of multiple elements side-by-side with
941 " different sizes, each of which has their own extra padding added. Thus, a
942 " column made up of one item of size 1 and another of size 2 would not
943 " necessarily be equal in size to another line's foldcolumn with a single
944 " item of size 3.
945 " 2. The extra padding added to the <input> elements adds up to make the
946 " foldcolumn and line number column too wide, especially in Webkit
947 " browsers.
948 "
949 " So, the full workaround is:
950 " 1. Define a default size in em, equal to the number of characters in the
951 " input element, in case javascript is disabled and the browser does not
952 " support the 'ch' unit. Unfortunately this makes Opera no longer work
953 " properly without javascript. 1em per character is much too wide but it
954 " looks better in webkit browsers than unaligned columns.
955 " 2. Insert the following javascript to run at page load, which checks for the
956 " width of a single character (in an extraneous page element inserted
957 " before the page title, and set to hidden) and compares it to the width of
958 " another extra <input> element with only one character. If the width
959 " matches, the script does nothing more, but if not, it will figure out the
960 " fraction of an em unit which would correspond with a ch unit if there
961 " were one, and set the containing element (<pre> or <div>) to a class with
962 " pre-defined rules which is closest to that fraction of an em. Rules are
963 " defined from 0.05 em to 1em per ch.
964 if !empty(s:settings.prevent_copy)
965 call extend(s:lines, [
966 \ '',
967 \ '/* simulate a "ch" unit by asking the browser how big a zero character is */',
968 \ 'function FixCharWidth() {',
969 \ ' /* get the hidden element which gives the width of a single character */',
970 \ ' var goodWidth = document.getElementById("oneCharWidth").clientWidth;',
971 \ ' /* get all input elements, we''ll filter on class later */',
972 \ ' var inputTags = document.getElementsByTagName("input");',
973 \ ' var ratio = 5;',
974 \ ' var inputWidth = document.getElementById("oneInputWidth").clientWidth;',
975 \ ' var emWidth = document.getElementById("oneEmWidth").clientWidth;',
976 \ ' if (inputWidth > goodWidth) {',
977 \ ' while (ratio < 100*goodWidth/emWidth && ratio < 100) {',
978 \ ' ratio += 5;',
979 \ ' }',
980 \ ' document.getElementById("vimCodeElement'.s:settings.id_suffix.'").className = "em"+ratio;',
981 \ ' }',
982 \ '}'
983 \ ])
984 endif
985
986 " insert script closing tag if needed 995 " insert script closing tag if needed
987 if s:uses_script 996 if s:uses_script
988 call extend(s:lines, [ 997 call extend(s:lines, [
989 \ '', 998 \ '',
990 \ s:settings.use_xhtml ? '//]]>' : '-->', 999 \ s:settings.use_xhtml ? '//]]>' : '-->',
991 \ "</script>" 1000 \ "</script>"
992 \ ]) 1001 \ ])
993 endif 1002 endif
994 1003
995 call extend(s:lines, ["</head>"]) 1004 call extend(s:lines, ["</head>",
996 if !empty(s:settings.prevent_copy) 1005 \ "<body".(s:settings.line_ids ? " onload='JumpToLine();'" : "").">"])
997 call extend(s:lines, 1006
998 \ ["<body onload='FixCharWidth();".(s:settings.line_ids ? " JumpToLine();" : "")."'>",
999 \ "<!-- hidden divs used by javascript to get the width of a char -->",
1000 \ "<div id='oneCharWidth'>0</div>",
1001 \ "<div id='oneInputWidth'><input size='1' value='0'".s:tag_close."</div>",
1002 \ "<div id='oneEmWidth' style='width: 1em;'></div>"
1003 \ ])
1004 else
1005 call extend(s:lines, ["<body".(s:settings.line_ids ? " onload='JumpToLine();'" : "").">"])
1006 endif
1007 if s:settings.no_pre 1007 if s:settings.no_pre
1008 " if we're not using CSS we use a font tag which can't have a div inside 1008 " if we're not using CSS we use a font tag which can't have a div inside
1009 if s:settings.use_css 1009 if s:settings.use_css
1010 call extend(s:lines, ["<div id='vimCodeElement".s:settings.id_suffix."'>"]) 1010 call extend(s:lines, ["<div id='vimCodeElement".s:settings.id_suffix."'>"])
1011 endif 1011 endif
1033 if !s:settings.no_progress 1033 if !s:settings.no_progress
1034 " ProgressBar Indicator 1034 " ProgressBar Indicator
1035 let s:progressbar={} 1035 let s:progressbar={}
1036 1036
1037 " Progessbar specific functions 1037 " Progessbar specific functions
1038
1039 func! s:SetProgbarColor()
1040 if hlID("TOhtmlProgress") != 0
1041 hi! link TOhtmlProgress_auto TOhtmlProgress
1042 elseif hlID("TOhtmlProgress_auto")==0 ||
1043 \ !exists("s:last_colors_name") || !exists("g:colors_name") ||
1044 \ g:colors_name != s:last_colors_name
1045 let s:last_colors_name = exists("g:colors_name") ? g:colors_name : "none"
1046
1047 let l:diffatr = synIDattr(hlID("DiffDelete"), "reverse", s:whatterm) ? "fg#" : "bg#"
1048 let l:stlatr = synIDattr(hlID("StatusLine"), "reverse", s:whatterm) ? "fg#" : "bg#"
1049
1050 let l:progbar_color = synIDattr(hlID("DiffDelete"), l:diffatr, s:whatterm)
1051 let l:stl_color = synIDattr(hlID("StatusLine"), l:stlatr, s:whatterm)
1052
1053 if "" == l:progbar_color
1054 let l:progbar_color = synIDattr(hlID("DiffDelete"), "reverse", s:whatterm) ? s:fgc : s:bgc
1055 endif
1056 if "" == l:stl_color
1057 let l:stl_color = synIDattr(hlID("StatusLine"), "reverse", s:whatterm) ? s:fgc : s:bgc
1058 endif
1059
1060 if l:progbar_color == l:stl_color
1061 if s:whatterm == 'cterm'
1062 if l:progbar_color >= (&t_Co/2)
1063 let l:progbar_color-=1
1064 else
1065 let l:progbar_color+=1
1066 endif
1067 else
1068 let l:rgb = map(matchlist(l:progbar_color, '#\zs\x\x\ze\(\x\x\)\(\x\x\)')[:2], 'str2nr(v:val, 16)')
1069 let l:avg = (l:rgb[0] + l:rgb[1] + l:rgb[2])/3
1070 if l:avg >= 128
1071 let l:avg_new = l:avg
1072 while l:avg - l:avg_new < 0x15
1073 let l:rgb = map(l:rgb, 'v:val * 3 / 4')
1074 let l:avg_new = (l:rgb[0] + l:rgb[1] + l:rgb[2])/3
1075 endwhile
1076 else
1077 let l:avg_new = l:avg
1078 while l:avg_new - l:avg < 0x15
1079 let l:rgb = map(l:rgb, 'min([max([v:val, 4]) * 5 / 4, 255])')
1080 let l:avg_new = (l:rgb[0] + l:rgb[1] + l:rgb[2])/3
1081 endwhile
1082 endif
1083 let l:progbar_color = printf("#%02x%02x%02x", l:rgb[0], l:rgb[1], l:rgb[2])
1084 endif
1085 echomsg "diff detected progbar color set to" l:progbar_color
1086 endif
1087 exe "hi TOhtmlProgress_auto" s:whatterm."bg=".l:progbar_color
1088 endif
1089 endfun
1090
1038 func! s:ProgressBar(title, max_value, winnr) 1091 func! s:ProgressBar(title, max_value, winnr)
1039 let pgb=copy(s:progressbar) 1092 let pgb=copy(s:progressbar)
1040 let pgb.title = a:title.' ' 1093 let pgb.title = a:title.' '
1041 let pgb.max_value = a:max_value 1094 let pgb.max_value = a:max_value
1042 let pgb.winnr = a:winnr 1095 let pgb.winnr = a:winnr
1043 let pgb.cur_value = 0 1096 let pgb.cur_value = 0
1097
1044 let pgb.items = { 'title' : { 'color' : 'Statusline' }, 1098 let pgb.items = { 'title' : { 'color' : 'Statusline' },
1045 \'bar' : { 'color' : 'Statusline' , 'fillcolor' : 'DiffDelete' , 'bg' : 'Statusline' } , 1099 \'bar' : { 'color' : 'Statusline' , 'fillcolor' : 'TOhtmlProgress_auto' , 'bg' : 'Statusline' } ,
1046 \'counter' : { 'color' : 'Statusline' } } 1100 \'counter' : { 'color' : 'Statusline' } }
1047 let pgb.last_value = 0 1101 let pgb.last_value = 0
1048 let pgb.needs_redraw = 0 1102 let pgb.needs_redraw = 0
1049 " Note that you must use len(split) instead of len() if you want to use 1103 " Note that you must use len(split) instead of len() if you want to use
1050 " unicode in title. 1104 " unicode in title.
1132 " }}} 1186 " }}}
1133 if s:settings.dynamic_folds 1187 if s:settings.dynamic_folds
1134 " to process folds we make two passes through each line 1188 " to process folds we make two passes through each line
1135 let s:pgb = s:ProgressBar("Processing folds:", line('$')*2, s:orgwin) 1189 let s:pgb = s:ProgressBar("Processing folds:", line('$')*2, s:orgwin)
1136 endif 1190 endif
1191
1192 call s:SetProgbarColor()
1137 endif 1193 endif
1138 1194
1139 " First do some preprocessing for dynamic folding. Do this for the entire file 1195 " First do some preprocessing for dynamic folding. Do this for the entire file
1140 " so we don't accidentally start within a closed fold or something. 1196 " so we don't accidentally start within a closed fold or something.
1141 let s:allfolds = [] 1197 let s:allfolds = []
1575 let s:tablist = [ &ts ] 1631 let s:tablist = [ &ts ]
1576 endif 1632 endif
1577 let s:tabidx = 0 1633 let s:tabidx = 0
1578 let s:tabwidth = 0 1634 let s:tabwidth = 0
1579 while s:idx >= 0 1635 while s:idx >= 0
1580 while s:startcol+s:idx > s:tabwidth + s:tablist[s:tabidx] 1636 if s:startcol + s:idx == 1
1581 let s:tabwidth += s:tablist[s:tabidx] 1637 let s:i = s:tablist[0]
1582 if s:tabidx < len(s:tablist)-1 1638 else
1583 let s:tabidx = s:tabidx+1 1639 " Get the character, which could be multiple bytes, which falls
1640 " immediately before the found tab. Extract it by matching a
1641 " character just prior to the column where the tab matches.
1642 " We'll use this to get the byte index of the character
1643 " immediately preceding the tab, so we can then look up the
1644 " virtual column that character appears in, to determine how
1645 " much of the current tabstop has been used up.
1646 if s:idx == 0
1647 " if the found tab is the first character in the text being
1648 " processed, we need to get the character prior to the text,
1649 " given by startcol.
1650 let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:offset) . 'c')
1651 else
1652 " Otherwise, the byte index of the tab into s:expandedtab is
1653 " given by s:idx.
1654 let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c')
1584 endif 1655 endif
1585 endwhile 1656 let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)])
1586 if has("multi_byte_encoding") 1657
1587 if s:startcol + s:idx == 1 1658 " find the tabstop interval to use for the tab we just found. Keep
1588 let s:i = s:tablist[s:tabidx] 1659 " adding tabstops (which could be variable) until we would exceed
1589 else 1660 " the virtual screen position of the start of the found tab.
1590 if s:idx == 0 1661 while s:vcol >= s:tabwidth + s:tablist[s:tabidx]
1591 let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:idx + s:offset) . 'c') 1662 let s:tabwidth += s:tablist[s:tabidx]
1592 else 1663 if s:tabidx < len(s:tablist)-1
1593 let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c') 1664 let s:tabidx = s:tabidx+1
1594 endif 1665 endif
1595 let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)]) 1666 endwhile
1596 let s:i = s:tablist[s:tabidx] - (s:vcol - s:tabwidth) 1667 let s:i = s:tablist[s:tabidx] - (s:vcol - s:tabwidth)
1597 endif
1598 let s:offset -= s:i - 1
1599 else
1600 let s:i = s:tablist[s:tabidx] - ((s:idx + s:startcol - 1) - s:tabwidth)
1601 endif 1668 endif
1669 " update offset to keep the index within the line corresponding to
1670 " actual tab characters instead of replaced spaces; s:idx reflects
1671 " replaced spaces in s:expandedtab, s:offset cancels out all but
1672 " the tab character itself.
1673 let s:offset -= s:i - 1
1602 let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '') 1674 let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '')
1603 let s:idx = stridx(s:expandedtab, "\t") 1675 let s:idx = stridx(s:expandedtab, "\t")
1604 endwhile 1676 endwhile
1605 end 1677 end
1606 1678
1672 " using a modeline. 1744 " using a modeline.
1673 call append(line('$'), "<!-- vim: set foldmethod=manual : -->") 1745 call append(line('$'), "<!-- vim: set foldmethod=manual : -->")
1674 1746
1675 " Now, when we finally know which, we define the colors and styles 1747 " Now, when we finally know which, we define the colors and styles
1676 if s:settings.use_css 1748 if s:settings.use_css
1677 1;/<style type="text/+1 1749 1;/<style\>/+1
1678 endif 1750 endif
1679 1751
1680 " Normal/global attributes 1752 " Normal/global attributes
1681 " For Netscape 4, set <body> attributes too, though, strictly speaking, it's
1682 " incorrect.
1683 if s:settings.use_css 1753 if s:settings.use_css
1684 if s:settings.no_pre 1754 if s:settings.no_pre
1685 call append('.', "body { color: " . s:fgc . "; background-color: " . s:bgc . "; font-family: ". s:htmlfont ."; }") 1755 call append('.', "body { color: " . s:fgc . "; background-color: " . s:bgc . "; font-family: ". s:htmlfont ."; }")
1686 + 1756 +
1687 else 1757 else
1700 call append('.', '* { font-size: 1em; }') 1770 call append('.', '* { font-size: 1em; }')
1701 + 1771 +
1702 " if we use any input elements for unselectable content, make sure they look 1772 " if we use any input elements for unselectable content, make sure they look
1703 " like normal text 1773 " like normal text
1704 if !empty(s:settings.prevent_copy) 1774 if !empty(s:settings.prevent_copy)
1705 call append('.', 'input { border: none; margin: 0; padding: 0; font-family: '.s:htmlfont.'; }') 1775 if s:settings.use_input_for_pc !=# "none"
1706 + 1776 call append('.', 'input { border: none; margin: 0; padding: 0; font-family: '.s:htmlfont.'; }')
1707 " ch units for browsers which support them, em units for a somewhat
1708 " reasonable fallback. Also make sure the special elements for size
1709 " calculations aren't seen.
1710 call append('.', [
1711 \ "input[size='1'] { width: 1em; width: 1ch; }",
1712 \ "input[size='2'] { width: 2em; width: 2ch; }",
1713 \ "input[size='3'] { width: 3em; width: 3ch; }",
1714 \ "input[size='4'] { width: 4em; width: 4ch; }",
1715 \ "input[size='5'] { width: 5em; width: 5ch; }",
1716 \ "input[size='6'] { width: 6em; width: 6ch; }",
1717 \ "input[size='7'] { width: 7em; width: 7ch; }",
1718 \ "input[size='8'] { width: 8em; width: 8ch; }",
1719 \ "input[size='9'] { width: 9em; width: 9ch; }",
1720 \ "input[size='10'] { width: 10em; width: 10ch; }",
1721 \ "input[size='11'] { width: 11em; width: 11ch; }",
1722 \ "input[size='12'] { width: 12em; width: 12ch; }",
1723 \ "input[size='13'] { width: 13em; width: 13ch; }",
1724 \ "input[size='14'] { width: 14em; width: 14ch; }",
1725 \ "input[size='15'] { width: 15em; width: 15ch; }",
1726 \ "input[size='16'] { width: 16em; width: 16ch; }",
1727 \ "input[size='17'] { width: 17em; width: 17ch; }",
1728 \ "input[size='18'] { width: 18em; width: 18ch; }",
1729 \ "input[size='19'] { width: 19em; width: 19ch; }",
1730 \ "input[size='20'] { width: 20em; width: 20ch; }",
1731 \ "#oneCharWidth, #oneEmWidth, #oneInputWidth { padding: 0; margin: 0; position: absolute; left: -999999px; visibility: hidden; }"
1732 \ ])
1733 +21
1734 for w in range(5, 100, 5)
1735 let base = 0.01 * w
1736 call append('.', join(map(range(1,20), "'.em'.w.' input[size='''.v:val.'''] { width: '.string(v:val*base).'em; }'")))
1737 + 1777 +
1738 endfor 1778 " ch units for browsers which support them, em units for a somewhat
1739 if s:settings.prevent_copy =~# 'f' 1779 " reasonable fallback.
1740 " Make the cursor show active fold columns as active areas, and empty fold 1780 for w in range(1, 20, 1)
1741 " columns as not interactive. 1781 call append('.', [
1742 call append('.', ['input.FoldColumn { cursor: pointer; }', 1782 \ "input[size='".w."'] { width: ".w."em; width: ".w."ch; }"
1743 \ 'input.FoldColumn[value=""] { cursor: default; }' 1783 \ ])
1744 \ ]) 1784 +
1745 +2 1785 endfor
1746 endif 1786 endif
1747 " make line number column show as non-interactive if not selectable 1787
1748 if s:settings.prevent_copy =~# 'n' 1788 if s:settings.use_input_for_pc !=# 'all'
1749 call append('.', 'input.LineNr { cursor: default; }') 1789 let s:unselectable_styles = []
1750 + 1790 if s:settings.prevent_copy =~# 'f'
1751 endif 1791 call add(s:unselectable_styles, 'FoldColumn')
1752 " make fold text and line number column within fold text show as 1792 endif
1753 " non-interactive if not selectable 1793 if s:settings.prevent_copy =~# 'n'
1754 if (s:settings.prevent_copy =~# 'n' || s:settings.prevent_copy =~# 't') && !s:settings.ignore_folding 1794 call add(s:unselectable_styles, 'LineNr')
1755 call append('.', 'input.Folded { cursor: default; }') 1795 endif
1756 + 1796 if s:settings.prevent_copy =~# 't' && !s:settings.ignore_folding
1757 endif 1797 call add(s:unselectable_styles, 'Folded')
1758 endif 1798 endif
1759 else 1799 if s:settings.prevent_copy =~# 'd'
1800 call add(s:unselectable_styles, 'DiffDelete')
1801 endif
1802 if s:settings.use_input_for_pc !=# 'none'
1803 call append('.', [
1804 \ '/* Note: IE does not support @supports conditionals, but also does not fully support',
1805 \ ' "content:" with custom content, so we *want* the check to fail */',
1806 \ '@supports ( content: attr(data-custom-content) ) {'
1807 \ ])
1808 +3
1809 endif
1810 " The line number column inside the foldtext is styled just like the fold
1811 " text in Vim, but it should use the prevent_copy settings of line number
1812 " rather than fold text. Apply the prevent_copy styles to foldtext
1813 " specifically for line numbers, which always come after the fold column,
1814 " or at the beginning of the line.
1815 if s:settings.prevent_copy =~# 'n' && !s:settings.ignore_folding
1816 call append('.', [
1817 \ ' .FoldColumn + .Folded, .Folded:first-child { user-select: none; }',
1818 \ ' .FoldColumn + [data-Folded-content]::before, [data-Folded-content]:first-child::before { content: attr(data-Folded-content); }',
1819 \ ' .FoldColumn + [data-Folded-content]::before, [data-Folded-content]:first-child::before { padding-bottom: 1px; display: inline-block; /* match the 1-px padding of standard items with background */ }',
1820 \ ' .FoldColumn + span[data-Folded-content]::before, [data-Folded-content]:first-child::before { cursor: default; }',
1821 \ ])
1822 +4
1823 endif
1824 for s:style_name in s:unselectable_styles
1825 call append('.', [
1826 \ ' .'.s:style_name.' { user-select: none; }',
1827 \ ' [data-'.s:style_name.'-content]::before { content: attr(data-'.s:style_name.'-content); }',
1828 \ ' [data-'.s:style_name.'-content]::before { padding-bottom: 1px; display: inline-block; /* match the 1-px padding of standard items with background */ }',
1829 \ ' span[data-'.s:style_name.'-content]::before { cursor: default; }',
1830 \ ])
1831 +4
1832 endfor
1833 if s:settings.use_input_for_pc !=# 'none'
1834 call append('.', [
1835 \ ' input { display: none; }',
1836 \ '}'
1837 \ ])
1838 +2
1839 endif
1840 unlet s:unselectable_styles
1841 endif
1842
1843 " Fix mouse cursor shape for the fallback <input> method of uncopyable text
1844 if s:settings.use_input_for_pc !=# 'none'
1845 if s:settings.prevent_copy =~# 'f'
1846 " Make the cursor show active fold columns as active areas, and empty fold
1847 " columns as not interactive.
1848 call append('.', ['input.FoldColumn { cursor: pointer; }',
1849 \ 'input.FoldColumn[value="'.repeat(' ', s:foldcolumn).'"] { cursor: default; }'
1850 \ ])
1851 +2
1852 if s:settings.use_input_for_pc !=# 'all'
1853 call append('.', [
1854 \ 'a[data-FoldColumn-content="'.repeat(' ', s:foldcolumn).'"] { cursor: default; }'
1855 \ ])
1856 +1
1857 end
1858 endif
1859 " make line number column show as non-interactive if not selectable
1860 if s:settings.prevent_copy =~# 'n'
1861 call append('.', 'input.LineNr { cursor: default; }')
1862 +
1863 endif
1864 " make fold text and line number column within fold text show as
1865 " non-interactive if not selectable
1866 if (s:settings.prevent_copy =~# 'n' || s:settings.prevent_copy =~# 't') && !s:settings.ignore_folding
1867 call append('.', 'input.Folded { cursor: default; }')
1868 +
1869 endif
1870 " make diff filler show as non-interactive if not selectable
1871 if s:settings.prevent_copy =~# 'd'
1872 call append('.', 'input.DiffDelete { cursor: default; }')
1873 +
1874 endif
1875 endif
1876 endif
1877 else
1878 " For Netscape 4, set <body> attributes too, though, strictly speaking, it's
1879 " incorrect.
1760 execute '%s:<body\([^>]*\):<body bgcolor="' . s:bgc . '" text="' . s:fgc . '"\1>\r<font face="'. s:htmlfont .'"' 1880 execute '%s:<body\([^>]*\):<body bgcolor="' . s:bgc . '" text="' . s:fgc . '"\1>\r<font face="'. s:htmlfont .'"'
1761 endif 1881 endif
1762 1882
1763 " Gather attributes for all other classes. Do diff first so that normal 1883 " Gather attributes for all other classes. Do diff first so that normal
1764 " highlight groups are inserted before it. 1884 " highlight groups are inserted before it.
1777 %s+\(https\=://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<a href="\1">\1</a>\2+ge 1897 %s+\(https\=://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<a href="\1">\1</a>\2+ge
1778 1898
1779 " The DTD 1899 " The DTD
1780 if s:settings.use_xhtml 1900 if s:settings.use_xhtml
1781 exe "normal! gg$a\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" 1901 exe "normal! gg$a\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
1782 elseif s:settings.use_css && !s:settings.no_pre 1902 elseif s:html5
1783 exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n" 1903 exe "normal! gg0i<!DOCTYPE html>\n"
1784 else 1904 else
1785 exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" 1905 exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
1786 endif 1906 endif
1787 1907
1788 if s:settings.use_xhtml 1908 if s:settings.use_xhtml
1821 let &l:stl = s:newwin_stl 1941 let &l:stl = s:newwin_stl
1822 exec 'resize' s:old_winheight 1942 exec 'resize' s:old_winheight
1823 let &l:winfixheight = s:old_winfixheight 1943 let &l:winfixheight = s:old_winfixheight
1824 1944
1825 let &ls=s:ls 1945 let &ls=s:ls
1946 let &eventignore=s:ei_sav
1826 1947
1827 " Save a little bit of memory (worth doing?) 1948 " Save a little bit of memory (worth doing?)
1828 unlet s:htmlfont s:whitespace 1949 unlet s:htmlfont s:whitespace
1829 unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search 1950 unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
1830 unlet s:old_magic s:old_more s:old_fen s:old_winheight 1951 unlet s:old_magic s:old_more s:old_fen s:old_winheight
1831 unlet! s:old_isprint 1952 unlet! s:old_isprint
1832 unlet s:whatterm s:stylelist s:diffstylelist s:lnum s:end s:margin s:fgc s:bgc s:old_winfixheight 1953 unlet s:whatterm s:stylelist s:diffstylelist s:lnum s:end s:margin s:fgc s:bgc s:old_winfixheight
1833 unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:concealinfo s:diff_mode 1954 unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:concealinfo s:diff_mode
1834 unlet! s:orgwin s:newwin s:orgbufnr s:idx s:i s:offset s:ls s:origwin_stl 1955 unlet! s:orgwin s:newwin s:orgbufnr s:idx s:i s:offset s:ls s:ei_sav s:origwin_stl
1835 unlet! s:newwin_stl s:current_syntax 1956 unlet! s:newwin_stl s:current_syntax
1836 if !v:profiling 1957 if !v:profiling
1837 delfunc s:HtmlColor 1958 delfunc s:HtmlColor
1838 delfunc s:HtmlFormat 1959 delfunc s:HtmlFormat
1839 delfunc s:CSS1 1960 delfunc s:CSS1