I just started looking into converting syntax highlighted code to
HTML (to be embedded on a web page).
Great feature! The only fly in the ointment is the fact that line
numbers are selectable.
I remember Ben Fritz tried to address this issue two months ago:
http://vim.1045645.n5.nabble.com/TOhtml-beta-release-unselectable-regions-td5560969.html
I have (manually) played around with the generated HTML and I have come
up with a solution that requires no javascript and the HTML code is a
bit more compact. I have attached a 5-line example.
The output is placed in a <table>, and the line numbers are in a
separate <td>. Consequently, it is possible to select the output code
without grabbing line numbers.
Although not essential in this set-up, it is possible to
make the line numbers unselectable just using CSS. I have enclosed a
cross-browser CSS solution for the unselectable line number area.
Disabling selectability might not work for every browser but this is
not crucial as it is possible to select the data content separately
anyway.
Internet Explorer versions <10 require a different approach: the tag
containing the line number needs to be given the "unselectable"
attribute. (This is not inherited and therefore cannot be added at
parent level!)
I also changed the cursor to pointer.
I made a point of keeping the CSS classes that reflext the vim colour
scheme (lnr, Identifier,...) separate from the generic CSS that
determines the page structure. This way one can easily paste in
additional syntax highlighting tags into an existing stylesheet.
I applied the lnr highlighting to the containing <pre> block rather
than every individual line so that the whole line number column has the
lnr background and it avoids gaps between rows.
The output validates with the exception of the IE "unselectable"
attribute.
PS: I don't have a Windows machine, so can't test this with IE.
--
Tarlika Elisabeth Schmitz, Scotland
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Thursday, May 10, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment