sponsor Vim development Vim logo Vim Book Ad

2htmlj : Slightly modified 2html.vim script for use with javadoc

 script karma  Rating 4/1, Downloaded by 848  Comments, bugs, improvements  Vim wiki

created by
Charles Shooshan
 
script type
syntax
 
description
I have modified the great 2html.vim script contained in the distribution for use with javadoc documents. My changes may be of use to others as well.

Specific purpose: when creating Java API Documents with the -linksource option, the documents include copies of source code but (glaring omission) the html source pages are not syntax-highlighted.

My changes to the 2html.vim script allow the resulting html documents to be exchanged with those in the src-html folder thus creating syntax-highlighted html pages in the API documentation.

The key addition is the "id" attribute at the beginning of each code line so that every line of code can be reached like this: Hello.html#line.15.

What was: <span class="lnr"> 11</span>
is now: <span id="line.11" class="lnr"> 11</span>

I also added the options of short_name and short_title so that Hello.java becomes Hello.html not Hello.java.html and that the html document title is the name of the source file.

Please see my comments in the script.

Note: I tried hard not to break anything in the existing script. I would appreciate any feedback. Thanks.
 
install details
You must place this file in the Vim syntax folder (on my Mac, it's at: /Applications/vim/Vim.app/runtime/syntax). You may rename it as 2html.vim and replace the existing script if you wish (please save the original if you do).

To use the javadoc functionality (with script saved as 2html.vim):
:let javadoc = 1
:runtime! syntax/2html.vim

To hide line numbers but still have the id references to line numbers:
:let javadoc_no_lnr = 1
:runtime! syntax/2html.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
2htmlj.vim 1.1 2004-06-01 6.0 Charles Shooshan Minor change so Windows GUI will leave path off html short_title. Line 206 of code changed from: let s:source_file = expand("%") to: let s:source_file = expand("%:t") .
2htmlj.vim 1.0 2004-05-31 6.0 Charles Shooshan Initial upload
ip used for rating: 3.134.118.95

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github