GNU Nano-style syntax highlighting on the web.
The highlighter is written in pure JavaScript, so no additional libraries are required. Just include the highlight and language files inside your .html project.
<link rel=stylesheet href=path/to/Language.css>
<script src=path/to/Language.js></script>
<script src=path/to/2001.js></script>
path/to/ | -> 2001.js
| -> Language.js
| -> Language.css
Insert code you want to highlight between <code>
tags, then add the correct language to let the script provide correct colouring.
<code class=Language>
Lorem Ipsum...
</code>
Function | |
---|---|
highlight() |
Adds correct syntax highlighting to all <code> blocks inside the file. |
var text = document.getElementById(id).innerText;
2001 supports different themes within a language.
- *.JS contains the regex and intended color code.
- *.CSS matches those color codes into the correct text color. By customising the .CSS file, or creating new files, you can use a different theme for a language.
Additional syntax themes for new languages, or new themes for currently supported languages, are always welcome. Ensure you make clear what language your are supporting and the name of your theme inside the pull request in order to get it accepted swiftly.