Less optimal HTML output?

51 views
Skip to first unread message

Yongwei Wu

unread,
Apr 12, 2016, 9:44:00 AM4/12/16
to vim
I noticed something weird recently in the VIM HTML output (CSS on). It
is probably there for quite some time now, but I checked the HTML
source only recently.

* { font-size: 1em; } (in CSS)

I do not see the point of this. It does not seem to affect the result
in Chrome, but it makes the font larger in IE than without it.

<script type='text/javascript'>
<!--

-->
</script>

Apparently it does nothing, but it triggers the IE warning: "Internet
Explorer restricted this web page from running scripts or ActiveX
controls."

Can it be regarded as bugs? Or is there a way to tune the output to
get rid of them?

(Now I have to remove them manually from the HTML.)

Best regards,

Yongwei

--
Wu Yongwei
URL: http://wyw.dcweb.cn/

Ben Fritz

unread,
Apr 12, 2016, 12:04:45 PM4/12/16
to vim_use, v...@vim.org
On Tuesday, April 12, 2016 at 8:44:00 AM UTC-5, Yongwei Wu wrote:
> I noticed something weird recently in the VIM HTML output (CSS on). It
> is probably there for quite some time now, but I checked the HTML
> source only recently.
>
> * { font-size: 1em; } (in CSS)
>
> I do not see the point of this. It does not seem to affect the result
> in Chrome, but it makes the font larger in IE than without it.
>

From 2html.vim:

" fix browser inconsistencies (sometimes within the same browser) of different
" default font size for different elements
call append('.', '* { font-size: 1em; }')

I'm not sure exactly what that means or when it was introduced, but I can look into it. Perhaps there is a better way to accomplish this.

I can confirm that the font gets bigger in IE with that in (actually it makes it match Firefox and Chrome fairly closely). This is weird; in a monospace font 1em should already be the width of a character. Setting it to 100% or 1rem instead of 1em seems to do the same thing. Ugh...IE.

Why is the larger text a problem? I figured consistency across browsers would be a good thing, not a bad one...

> <script type='text/javascript'>
> <!--
>
> -->
> </script>
>
> Apparently it does nothing, but it triggers the IE warning: "Internet
> Explorer restricted this web page from running scripts or ActiveX
> controls."
>

It's a bug that an empty script tag is generated; apparently you don't have any options enabled that use javascript (dynamic folds, uncopyable regions, jumping to specific lines). Previously the line-jumping script was always added, now it has an option to remove it. Now that the option is there, the <script> tag should also be removed if there will be no content. I just created an issue for this:

https://bitbucket.org/fritzophrenic/vim-tohtml/issues/6/empty-script-tag-should-not-be-generated

Yongwei Wu

unread,
Apr 12, 2016, 10:12:13 PM4/12/16
to vim...@googlegroups.com
On 13 April 2016 at 00:04, Ben Fritz <fritzo...@gmail.com> wrote:
> On Tuesday, April 12, 2016 at 8:44:00 AM UTC-5, Yongwei Wu wrote:
>> I noticed something weird recently in the VIM HTML output (CSS on). It
>> is probably there for quite some time now, but I checked the HTML
>> source only recently.
>>
>> * { font-size: 1em; } (in CSS)
>>
>> I do not see the point of this. It does not seem to affect the result
>> in Chrome, but it makes the font larger in IE than without it.
>>
>
> From 2html.vim:
>
> " fix browser inconsistencies (sometimes within the same browser) of different
> " default font size for different elements
> call append('.', '* { font-size: 1em; }')
>
> I'm not sure exactly what that means or when it was introduced, but I can look into it. Perhaps there is a better way to accomplish this.
>
> I can confirm that the font gets bigger in IE with that in (actually it makes it match Firefox and Chrome fairly closely). This is weird; in a monospace font 1em should already be the width of a character. Setting it to 100% or 1rem instead of 1em seems to do the same thing. Ugh...IE.
>
> Why is the larger text a problem? I figured consistency across browsers would be a good thing, not a bad one...

I think this is dependent on the browser configuration. In my case,
the IE font size with 1 em is apparent bigger than other cases. In
other browsers (with or without 1 em) or IE without 1 em, I get the
standard 10 pt (13 px) Courier New as output.

I guess the reason is that the standard CSS in IE has 10 pt Courier
New for <pre>, and 12 pt ... for <body>. "font-size: 1em" makes <pre>
use 12 pt as well. For some reasons Chrome is not affected by
"font-size: 1em": I verified that it thinks the font-size is still 13
px, the default setting.

Benjamin Fritz

unread,
Apr 13, 2016, 1:25:17 AM4/13/16
to vim_use

On Tue, Apr 12, 2016 at 9:12 PM, Yongwei Wu <wuyo...@gmail.com> wrote:
>
> I think this is dependent on the browser configuration. In my case,
> the IE font size with 1 em is apparent bigger than other cases. In
> other browsers (with or without 1 em) or IE without 1 em, I get the
> standard 10 pt (13 px) Courier New as output.
>
> I guess the reason is that the standard CSS in IE has 10 pt Courier
> New for <pre>, and 12 pt ... for <body>. "font-size: 1em" makes <pre>
> use 12 pt as well. For some reasons Chrome is not affected by
> "font-size: 1em": I verified that it thinks the font-size is still 13
> px, the default setting.

A feature I was thinking about was to auto-detect font name and font size, and apply that.

This would apply the same font size from Vim to the document instead of "1em". And obviously, a manual setting would go along with that.

Not sure if this would solve your problem as well or if you want the line gone entirely.

Probably the targeting could be more precise.

Yongwei Wu

unread,
Apr 18, 2016, 12:57:35 AM4/18/16
to vim...@googlegroups.com
Unless we can find a reason when "* { font-size: 1em; }" is useful,
the simple solution seem just to remove this line. That was the way
Vim used to be.

Can we find out when and why it was introduced?
Reply all
Reply to author
Forward
0 new messages