Convert2HTML

From Niki

Jump to: navigation, search

sh2html.nm

This macro will take a file, open it in NEdit (if not already open) and create one or two more files containing a HMTL representation of the first file's syntax highlighting, including CSS.

Note: you might have to uncomment the definitions of chomp(), basename() and dirname() at the end of the file, since these are not standard routines.

The macro takes a single parameter, an array containing the following keys:

  • source - source file name; relative pathes are prepended by $PWD (mandatory)
  • html - html file name; relative pathes are prepended by source's dirname (defaults to source".html")
  • css - css file name or "INLINE" for inline css; relative pathes are prepended by source's dirname (defaults to source".css")
  • numbered - set for applying line numbers (defaults to unset)
  • mode - language mode to use (defaults to whatever your NEdit comes up with for the source file)

There is not much experince with using a single array as a function's parameters, so contact the author with any thoughts you have about this. If you really hate it and the author does not listen to you it should be easy to write a wrapper which creates the array.


A typical application converts the current file:

    params = $empty_array
    params[["source"]] = $file_name
    sh2html(params)

Throw in

    params[["css"]] = "INLINE"

if you don't like CSS files.


  • This macro is currently the only way to print NEdit's syntax highlighting. Just convert it into HTML and use your browser to print.
  • It is a resource-hog. Creating a second-generation file (ie. the HTML representation of your file's HTML representation) is already reason to get up and make coffee. Anything more than that is asking for trouble because you might dicover some of the finer points of NEdit's resource handling for the macro language.
  • This is only really tested with itself. Contact the author if you have trouble with any other language mode.
  • The author can be reached at nedit&thorstenhau,de.

Copyright 2002, 2004 Thorsten Haude, HTML validification by Joor Loohuis

This is free software; you may modify and redistribute it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. (http://www.gnu.org/licenses/gpl.html)