11" Vim autoload file for the tohtml plugin.
22" Maintainer: Ben Fritz <[email protected] >3- " Last Change: 2011 Jan 05
3+ " Last Change: 2011 Apr 05
44"
55" Additional contributors:
66"
@@ -16,7 +16,7 @@ set cpo-=C
1616" Automatically find charsets from all encodings supported natively by Vim. With
1717" the 8bit- and 2byte- prefixes, Vim can actually support more encodings than
1818" this. Let the user specify these however since they won't be supported on
19- " every system. TODO: how? g:html_charsets and g:html_encodings?
19+ " every system.
2020"
2121" Note, not all of Vim's supported encodings have a charset to use.
2222"
@@ -312,8 +312,9 @@ func! tohtml#Convert2HTML(line1, line2) "{{{
312312 " figure out whether current charset and encoding will work, if not
313313 " default to UTF-8
314314 if ! exists (' g:html_use_encoding' ) &&
315- \ (&l: fileencoding!= ' ' && &l: fileencoding!= s: settings .vim_encoding ||
316- \ &l: fileencoding== ' ' && &encoding != s: settings .vim_encoding)
315+ \ (((&l: fileencoding== ' ' || (&l: buftype!= ' ' && &l: buftype!=? ' help' ))
316+ \ && &encoding !=? s: settings .vim_encoding)
317+ \ || &l: fileencoding!= ' ' && &l: fileencoding!=? s: settings .vim_encoding)
317318 echohl WarningMsg
318319 echomsg " TOhtml: mismatched file encodings in Diff buffers, using UTF-8"
319320 echohl None
@@ -603,6 +604,7 @@ func! tohtml#GetUserSettings() "{{{
603604 call tohtml#GetOption (user_settings, ' no_progress' , ! has (" statusline" ) )
604605 call tohtml#GetOption (user_settings, ' diff_one_file' , 0 )
605606 call tohtml#GetOption (user_settings, ' number_lines' , &number )
607+ call tohtml#GetOption (user_settings, ' pre_wrap' , &wrap )
606608 call tohtml#GetOption (user_settings, ' use_css' , 1 )
607609 call tohtml#GetOption (user_settings, ' ignore_conceal' , 0 )
608610 call tohtml#GetOption (user_settings, ' ignore_folding' , 0 )
@@ -641,7 +643,13 @@ func! tohtml#GetUserSettings() "{{{
641643 " aren't allowed inside a <pre> block
642644 if ! user_settings.use_css
643645 let user_settings.no_pre = 1
644- endif " }}}
646+ endif
647+
648+ " pre_wrap doesn't do anything if not using pre or not using CSS
649+ if user_settings.no_pre || ! user_settings.use_css
650+ let user_settings.pre_wrap= 0
651+ endif
652+ " }}}
645653
646654 " set up expand_tabs option after all the overrides so we know the
647655 " appropriate defaults {{{
@@ -669,9 +677,16 @@ func! tohtml#GetUserSettings() "{{{
669677 endif
670678 else
671679 " Figure out proper MIME charset from 'fileencoding' if possible
672- if &l: fileencoding != ' '
673- let user_settings.vim_encoding = &l: fileencoding
674- call tohtml#CharsetFromEncoding (user_settings)
680+ if &l: fileencoding != ' '
681+ " If the buffer is not a "normal" type, the 'fileencoding' value may not
682+ " be trusted; since the buffer should not be written the fileencoding is
683+ " not intended to be used.
684+ if &l: buftype== ' ' || &l: buftype== ?' help'
685+ let user_settings.vim_encoding = &l: fileencoding
686+ call tohtml#CharsetFromEncoding (user_settings)
687+ else
688+ let user_settings.encoding = ' ' " trigger detection using &encoding
689+ endif
675690 endif
676691
677692 " else from 'encoding' if possible
0 commit comments