11" Vim autoload file for the tohtml plugin.
22" Maintainer: Ben Fritz <[email protected] >3- " Last Change: 2013 May 31
3+ " Last Change: 2013 Jun 19
44"
55" Additional contributors:
66"
@@ -401,15 +401,15 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
401401 call add (html, ' </head>' )
402402 let body_line_num = len (html)
403403 if ! empty (s: settings .prevent_copy)
404- call add (html, " <body onload='FixCharWidth(); JumpToLine();'>" )
404+ call add (html, " <body onload='FixCharWidth();" .( s: settings .line_ids ? " JumpToLine();" : " " ). " '>" )
405405 call add (html, " <!-- hidden divs used by javascript to get the width of a char -->" )
406406 call add (html, " <div id='oneCharWidth'>0</div>" )
407407 call add (html, " <div id='oneInputWidth'><input size='1' value='0'" .tag_close." </div>" )
408408 call add (html, " <div id='oneEmWidth' style='width: 1em;'></div>" )
409409 else
410- call add (html, ' <body onload="JumpToLine();">' )
410+ call add (html, ' <body' .( s: settings .line_ids ? ' onload="JumpToLine();"' : ' ' ). ' >' )
411411 endif
412- call add (html, " <table border='1' width='100%' id='vimCodeElement'>" )
412+ call add (html, " <table border='1' width='100%' id='vimCodeElement" . s: settings .id_suffix. " '>" )
413413
414414 call add (html, ' <tr>' )
415415 for buf in a: win_list
@@ -475,7 +475,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
475475 let temp = getline (1 ,' $' )
476476 " clean out id on the main content container because we already set it on
477477 " the table
478- let temp[0 ] = substitute (temp[0 ], " id='vimCodeElement'" , " " , " " )
478+ let temp[0 ] = substitute (temp[0 ], " id='vimCodeElement[^']* '" , " " , " " )
479479 " undo deletion of start and end part
480480 " so we can later save the file as valid html
481481 " TODO: restore using grabbed lines if undolevel is 1?
@@ -568,9 +568,9 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
568568 \ ' var emWidth = document.getElementById("oneEmWidth").clientWidth;' ,
569569 \ ' if (inputWidth > goodWidth) {' ,
570570 \ ' while (ratio < 100*goodWidth/emWidth && ratio < 100) {' ,
571- \ ' ratio += 5;' ,
572- \ ' }' ,
573- \ ' document.getElementById("vimCodeElement").className = "em"+ratio;' ,
571+ \ ' ratio += 5;' ,
572+ \ ' }' ,
573+ \ ' document.getElementById("vimCodeElement' . s: settings .id_suffix. ' ").className = "em"+ratio;' ,
574574 \ ' }' ,
575575 \ ' }'
576576 \ ])
@@ -596,7 +596,7 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
596596 \ " " ,
597597 \ " /* navigate upwards in the DOM tree to open all folds containing the line */" ,
598598 \ " var node = lineElem;" ,
599- \ " while (node && node.id != 'vimCodeElement')" ,
599+ \ " while (node && node.id != 'vimCodeElement" . s: settings .id_suffix. " ')" ,
600600 \ " {" ,
601601 \ " if (node.className == 'closed-fold')" ,
602602 \ " {" ,
@@ -722,6 +722,7 @@ func! tohtml#GetUserSettings() "{{{
722722 call tohtml#GetOption (user_settings, ' no_invalid' , 0 )
723723 call tohtml#GetOption (user_settings, ' whole_filler' , 0 )
724724 call tohtml#GetOption (user_settings, ' use_xhtml' , 0 )
725+ call tohtml#GetOption (user_settings, ' line_ids' , user_settings.number_lines )
725726 " }}}
726727
727728 " override those settings that need it {{{
@@ -855,6 +856,20 @@ func! tohtml#GetUserSettings() "{{{
855856 let user_settings.no_invalid = 0
856857 endif
857858
859+ if exists (' g:html_id_expr' )
860+ let user_settings.id_suffix = eval (g: html_id_expr )
861+ if user_settings.id_suffix !~ ' ^[-_:.A-Za-z0-9]*$'
862+ echohl WarningMsg
863+ echomsg ' 2html: g:html_id_expr evaluated to invalid string for HTML id attributes'
864+ echomsg ' 2html: Omitting user-specified suffix'
865+ echohl None
866+ sleep 3
867+ let user_settings.id_suffix= " "
868+ endif
869+ else
870+ let user_settings.id_suffix= " "
871+ endif
872+
858873 " TODO: font
859874
860875 return user_settings
0 commit comments