I’m looking for a tool that takes code as input and outputs this code as syntax highlighted HTML+CSS.

It can either be a local tool (running natively on GNU/Linux) or a self-hosted web app (Linux server). In either case, it must be FLOSS.


I only need support for "Web languages" (i.e., XML, HTML, CSS and JavaScript). But support for more languages is welcome, of course.

The tool doesn’t have to guess the language; I’m fine with selecting it.


It should escape characters that might conflict with (X)HTML, e.g. < as &lt;.

It should use only div and span elements to markup the code.

It should not use the style attribute! Either use the style element (so I can copy the CSS and paste it into my stylesheet) or offer a separate CSS file.

For that, it should use class attributes (data-* is okay, too). At best it uses semantic class values, and some kind of prefix to avoid name conflicts.

Just to give a poor example, here is an HTML input followed by an acceptable output:

<p>Lheben teil brann i annon ar <b id="foo">neledh</b> neledhi gar godrebh.</p>
<span class="sh-html-tag">&lt;p&gt;</span>Lheben teil brann i annon ar <span class="sh-html-tag">&lt;b <span class="sh-html-attribute">id="foo"</span>&gt;</span>neledh<span class="sh-html-tag">&lt;/b&gt;</span> neledhi gar godrebh.<span class="sh-html-tag">&lt;/p&gt;</span>

1 Answer 1


I once wrote that for iFAQMaker, which is no longer maintained. An example of code output you can find in the Demo page:

iFAQMaker Demo

Input are basically text files with macros supported. This example uses the sqlfile macro, resulting in the text syntax highlighted as SQL, plus a link to download the original file. There are *file macros available for SQL, PHP, and Shell, and you can extend the API with additional ones if needed.

How does it fit your requirements:

  • self-hosted web app (Linux server): iFAQMaker is a PHP application/script.
  • FLOSS: Yes (GPLv2)
  • XML, HTML, CSS and JavaScript: As it ships, only SQL, PHP, and Shell. Given a keyword list, you can easily add all languages you want.
  • escape characters: Yes, it does.
  • should use only div and span elements to markup the code: Yupp.
  • not use the style attribute: Nope. Uses CSS classes with a specific (external) stylesheet

Not a perfect match (as you'd have to create the keyword lists for your major languages first), but I hope it's useful nevertheless. I'm using it a lot on my websites for exactly this: displaying scripts inline syntax-highlighted, while at the same time offering them for download.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.