11" Vim autoload file for the tohtml plugin.
22" Maintainer: Ben Fritz <[email protected] >3- " Last Change: 2023 Jan 01
3+ " Last Change: 2023 Sep 03
44"
55" Additional contributors:
66"
@@ -307,7 +307,7 @@ func! tohtml#Convert2HTML(line1, line2) "{{{
307307 let g: html_diff_win_num = 0
308308 for window in win_list
309309 " switch to the next buffer to convert
310- exe " :" . bufwinnr (window ) . " wincmd w"
310+ exe " :" .. bufwinnr (window ) . . " wincmd w"
311311
312312 " figure out whether current charset and encoding will work, if not
313313 " default to UTF-8
@@ -355,7 +355,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
355355 if ! s: settings .no_doc
356356 if s: settings .use_xhtml
357357 if s: settings .encoding != " "
358- let xml_line = " <?xml version=\" 1.0\" encoding=\" " . s: settings .encoding . " \" ?>"
358+ let xml_line = " <?xml version=\" 1.0\" encoding=\" " .. s: settings .encoding . . " \" ?>"
359359 else
360360 let xml_line = " <?xml version=\" 1.0\" ?>"
361361 endif
@@ -387,34 +387,34 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
387387 " contained in XML information
388388 if s: settings .encoding != " " && ! s: settings .use_xhtml
389389 if s: html5
390- call add (html, ' <meta charset="' . s: settings .encoding . ' "' . tag_close)
390+ call add (html, ' <meta charset="' .. s: settings .encoding .. ' "' . . tag_close)
391391 else
392- call add (html, " <meta http-equiv=\" content-type\" content=\" text/html; charset=" . s: settings .encoding . ' "' . tag_close)
392+ call add (html, " <meta http-equiv=\" content-type\" content=\" text/html; charset=" .. s: settings .encoding .. ' "' . . tag_close)
393393 endif
394394 endif
395395
396396 call add (html, ' <title>diff</title>' )
397- call add (html, ' <meta name="Generator" content="Vim/' .v: version /100 .' .' .v: version% 100 .' "' .tag_close)
398- call add (html, ' <meta name="plugin-version" content="' .g: loaded_2html_plugin .' "' .tag_close)
397+ call add (html, ' <meta name="Generator" content="Vim/' .. v: version /100 .. ' .' .. v: version% 100 .. ' "' . .tag_close)
398+ call add (html, ' <meta name="plugin-version" content="' .. g: loaded_2html_plugin .. ' "' . .tag_close)
399399 call add (html, ' <meta name="settings" content="' .
400400 \ join (filter (keys (s: settings ),' s:settings[v:val]' ),' ,' ).
401- \ ' ,prevent_copy=' .s: settings .prevent_copy.
402- \ ' ,use_input_for_pc=' .s: settings .use_input_for_pc.
403- \ ' "' .tag_close)
401+ \ ' ,prevent_copy=' .. s: settings .prevent_copy.
402+ \ ' ,use_input_for_pc=' .. s: settings .use_input_for_pc.
403+ \ ' "' .. tag_close)
404404 call add (html, ' <meta name="colorscheme" content="' .
405405 \ (exists (' g:colors_name' )
406406 \ ? g: colors_name
407- \ : ' none' ). ' "' .tag_close)
407+ \ : ' none' ).. ' "' . .tag_close)
408408
409409 call add (html, ' </head>' )
410410 let body_line_num = len (html)
411- call add (html, ' <body' .(s: settings .line_ids ? ' onload="JumpToLine();"' : ' ' ).' >' )
411+ call add (html, ' <body' .. (s: settings .line_ids ? ' onload="JumpToLine();"' : ' ' ). .' >' )
412412 endif
413- call add (html, " <table " .(s: settings .use_css? " " : " border='1' width='100%' " )." id='vimCodeElement" .s: settings .id_suffix." '>" )
413+ call add (html, " <table " .. (s: settings .use_css? " " : " border='1' width='100%' " ).. " id='vimCodeElement" .. s: settings .id_suffix. ." '>" )
414414
415415 call add (html, ' <tr>' )
416416 for buf in a: win_list
417- call add (html, ' <th>' .bufname (buf ).' </th>' )
417+ call add (html, ' <th>' .. bufname (buf ). .' </th>' )
418418 endfor
419419 call add (html, ' </tr><tr>' )
420420
@@ -423,7 +423,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
423423
424424 for buf in a: buf_list
425425 let temp = []
426- exe bufwinnr (buf ) . ' wincmd w'
426+ exe bufwinnr (buf ) .. ' wincmd w'
427427
428428 " If text is folded because of user foldmethod settings, etc. we don't want
429429 " to act on everything in a fold by mistake.
@@ -526,16 +526,16 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
526526 endif
527527
528528 let i = 1
529- let name = " Diff" . (s: settings .use_xhtml ? " .xhtml" : " .html" )
529+ let name = " Diff" .. (s: settings .use_xhtml ? " .xhtml" : " .html" )
530530 " Find an unused file name if current file name is already in use
531531 while filereadable (name)
532- let name = substitute (name, ' \d*\.x\?html$' , ' ' , ' ' ) . i . ' .' . fnamemodify (copy (name), " :t:e" )
532+ let name = substitute (name, ' \d*\.x\?html$' , ' ' , ' ' ) .. i .. ' .' . . fnamemodify (copy (name), " :t:e" )
533533 let i += 1
534534 endwhile
535535
536536 let s: ei_sav = &eventignore
537537 set eventignore += FileType
538- exe " topleft new " . name
538+ exe " topleft new " .. name
539539 let &eventignore = s: ei_sav
540540 unlet s: ei_sav
541541
@@ -601,7 +601,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
601601 \ " " ,
602602 \ " /* navigate upwards in the DOM tree to open all folds containing the line */" ,
603603 \ " var node = lineElem;" ,
604- \ " while (node && node.id != 'vimCodeElement" .s: settings .id_suffix." ')" ,
604+ \ " while (node && node.id != 'vimCodeElement" .. s: settings .id_suffix. ." ')" ,
605605 \ " {" ,
606606 \ " if (node.className == 'closed-fold')" ,
607607 \ " {" ,
@@ -640,7 +640,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
640640 call append (style_start, [
641641 \ " function toggleFold(objID)" ,
642642 \ " {" ,
643- \ " for (win_num = 1; win_num <= " .len (a: buf_list )." ; win_num++)" ,
643+ \ " for (win_num = 1; win_num <= " .. len (a: buf_list ). ." ; win_num++)" ,
644644 \ " {" ,
645645 \ " var fold;" ,
646646 \ ' fold = document.getElementById("win"+win_num+objID);' ,
@@ -660,7 +660,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
660660 if s: uses_script
661661 " insert script tag if needed
662662 call append (style_start, [
663- \ " <script" . (s: html5 ? " " : " type='text/javascript'" ) . " >" ,
663+ \ " <script" .. (s: html5 ? " " : " type='text/javascript'" ) . . " >" ,
664664 \ s: settings .use_xhtml ? ' //<![CDATA[' : " <!--" ])
665665 endif
666666
@@ -671,14 +671,14 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
671671 " is pretty useless for really long lines. {{{
672672 if s: settings .use_css
673673 call append (style_start,
674- \ [' <style' . (s: html5 ? ' ' : ' type="text/css"' ) . ' >' ]+
674+ \ [' <style' .. (s: html5 ? ' ' : ' type="text/css"' ) . . ' >' ]+
675675 \ style+
676676 \ [ s: settings .use_xhtml ? ' ' : ' <!--' ,
677677 \ ' table { table-layout: fixed; }' ,
678678 \ ' html, body, table, tbody { width: 100%; margin: 0; padding: 0; }' ,
679679 \ ' table, td, th { border: 1px solid; }' ,
680680 \ ' td { vertical-align: top; }' ,
681- \ ' th, td { width: ' .printf (" %.1f" ,100.0 /len (a: win_list )).' %; }' ,
681+ \ ' th, td { width: ' .. printf (" %.1f" ,100.0 /len (a: win_list )). .' %; }' ,
682682 \ ' td div { overflow: auto; }' ,
683683 \ s: settings .use_xhtml ? ' ' : ' -->' ,
684684 \ ' </style>'
@@ -694,7 +694,7 @@ endfunc "}}}
694694" Gets a single user option and sets it in the passed-in Dict, or gives it the
695695" default value if the option doesn't actually exist.
696696func ! tohtml#GetOption (settings, option , default) " {{{
697- if exists (' g:html_' .a: option )
697+ if exists (' g:html_' .. a: option )
698698 let a: settings [a: option ] = g: html_ {a: option }
699699 else
700700 let a: settings [a: option ] = a: default
@@ -713,10 +713,11 @@ func! tohtml#GetUserSettings() "{{{
713713 let user_settings = {}
714714
715715 " Define the correct option if the old option name exists and we haven't
716- " already defined the correct one. Maybe I'll put out a warning message about
717- " this sometime and remove the old option entirely at some even later time,
718- " but for now just silently accept the old option.
716+ " already defined the correct one.
719717 if exists (' g:use_xhtml' ) && ! exists (" g:html_use_xhtml" )
718+ echohl WarningMsg
719+ echomsg " Warning: g:use_xhtml is deprecated, use g:html_use_xhtml"
720+ echohl None
720721 let g: html_use_xhtml = g: use_xhtml
721722 endif
722723
@@ -739,7 +740,7 @@ func! tohtml#GetUserSettings() "{{{
739740 call tohtml#GetOption (user_settings, ' whole_filler' , 0 )
740741 call tohtml#GetOption (user_settings, ' use_xhtml' , 0 )
741742 call tohtml#GetOption (user_settings, ' line_ids' , user_settings.number_lines )
742- call tohtml#GetOption (user_settings, ' use_input_for_pc' , ' fallback ' )
743+ call tohtml#GetOption (user_settings, ' use_input_for_pc' , ' none ' )
743744 " }}}
744745
745746 " override those settings that need it {{{
@@ -854,16 +855,16 @@ func! tohtml#GetUserSettings() "{{{
854855 if user_settings.use_css
855856 if exists (" g:html_prevent_copy" )
856857 if user_settings.dynamic_folds && ! user_settings.no_foldcolumn && g: html_prevent_copy = ~# ' f'
857- let user_settings.prevent_copy .= ' f'
858+ let user_settings.prevent_copy .. = ' f'
858859 endif
859860 if user_settings.number_lines && g: html_prevent_copy = ~# ' n'
860- let user_settings.prevent_copy .= ' n'
861+ let user_settings.prevent_copy .. = ' n'
861862 endif
862863 if &diff && g: html_prevent_copy = ~# ' d'
863- let user_settings.prevent_copy .= ' d'
864+ let user_settings.prevent_copy .. = ' d'
864865 endif
865866 if ! user_settings.ignore_folding && g: html_prevent_copy = ~# ' t'
866- let user_settings.prevent_copy .= ' t'
867+ let user_settings.prevent_copy .. = ' t'
867868 endif
868869 else
869870 let user_settings.prevent_copy = " "
@@ -875,10 +876,10 @@ func! tohtml#GetUserSettings() "{{{
875876
876877 " enforce valid values for use_input_for_pc
877878 if user_settings.use_input_for_pc !~# ' fallback\|none\|all'
878- let user_settings.use_input_for_pc = ' fallback '
879+ let user_settings.use_input_for_pc = ' none '
879880 echohl WarningMsg
880- echomsg ' 2html: "' . g: html_use_input_for_pc . ' " is not valid for g:html_use_input_for_pc'
881- echomsg ' 2html: defaulting to "' . user_settings.use_input_for_pc . ' "'
881+ echomsg ' 2html: "' .. g: html_use_input_for_pc . . ' " is not valid for g:html_use_input_for_pc'
882+ echomsg ' 2html: defaulting to "' .. user_settings.use_input_for_pc . . ' "'
882883 echohl None
883884 sleep 3
884885 endif
0 commit comments