1

My python code opens a subprocess which in turn calls vimdiff and :toHTML.

Snippet added below:

subprocess.check_call(
            [
                "vimdiff",
                oldfileresultnameafterrename,
                build_xml_path,
                "-c",
                ":se nu | TOhtml | w! "+oldfileresultnameafterrename+".html | qa!"
            ]

In CentOS, it generates an HTML output and everything works as expected. Now I'm migrating to Ubuntu and the same command generates a HTML5 page.

Is there a way, I can generate a HTML page similar to the one generated in CentOS?

2
  • I suspect both distribution to not use the same version of Vim. Can you tell us what is the output of :version Vim command on both systems? Commented Dec 28, 2023 at 8:33
  • 2
    Hi, CentOS VIM - Vi IMproved 7.4 and Ubuntu VIM - Vi IMproved 8.2 Commented Dec 28, 2023 at 9:31

1 Answer 1

0

The two Vims are probably two different versions, with two different versions of the :TOhtml script. Compare the output of $ vim --version in both environments to make sure.

Anyway, the version I currently use (9.0_v2 in Vim 9.0.1897) exposes the :help g:html_use_css option which, rather unintuitively, switches the rendered HTML to 4.01:

" option
:let g:html_use_css = 0

" output
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
[…]

" option (default value)
:let g:html_use_css = 1

" output
<!DOCTYPE html>
[…]

If I were you I would try to convince the maintainer of that script to refactor it a bit for clarity. Something like g:html_use_html5 would be so much better.

2
  • CentOS is running on Vim 7.4 and Ubuntu on 8.2, I upgraded it to version 9.0 and added let g:html_use_css = 0 in the Vimrc. Now the HTML generated is missing the CSS, which was required to find the element using XPATH. Commented Dec 28, 2023 at 10:46
  • Well… it looks like you are left with playing with the options under :help :tohtml and/or opening an issue in Vim's issue tracker. Commented Dec 28, 2023 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.