Syntax highlighter for ABAP, HTML, XML, CSS, JavaScript, JSON, Markdown, and more.
NO WARRANTIES, MIT License
For example, here's how you highlight keywords and comments in a line of ABAP code:
DATA(highlighter) = zcl_highlighter_factory=>create( 'file.abap' ).
DATA(code) = `call function 'FM_NAME'. " Commented`.
DATA(html) = highlighter->process_line( code ).
WRITE html.
Output:
call function 'FM_NAME'. " Commmented
<span class="keyword">call</span> <span class="keyword">function</span> <span class="text">'FM_NAME'</span>. <span class="comment">" Commented</span>
Note
It's recommended to process one line at a time instead of passing a long string containing newline separators.
The language is derived from the extension of the filename passed to the factory:
Extension | Syntax Highlighter |
---|---|
.abap |
ABAP Code |
.css |
CSS3 |
.diff |
Git Diff |
.html |
HTML |
.ini |
Plain Text |
.js |
JavaScript |
.json |
JSON |
.json5 |
JSON5 (limited support for comments) |
.jsonc |
JSON (with end-of-line comments) |
.markdown |
Markdown |
.md |
Markdown |
.sass |
SASS |
.scss |
SCSS |
.text |
Plain Text |
.txt |
Plain Text |
.xml |
XML |
.yaml |
YAML (experimental) |
.yml |
YAML (experimental) |
Options:
You can show invisible characters in the output by settings an option in the factory call. This will highlight the following characters: horizontal tab (x09), form feed (x0C), carriage return (x0D), space (x20), as well as byte-order-marks (BOM) for UTF-8 (xEF BB BF), UTF-16 big-endian (xFE FF), and UTF-16 little-endian (xFF FE).
DATA(highlighter) = zcl_highlighter_factory=>create(
filename = 'file.abap'
hidden_chars = abap_true ).
SAP Basis 7.40 or higher
Install syntax-highlighter
as a global module in your system using apm.
or
Specify the syntax-highlighter
module as a dependency in your project and import it to your namespace using apm.
All contributions are welcome! Read our Contribution Guidelines, fork this repo, and create a pull request.
You can install the developer version of ABAP SYNTAX-HIGHLIGHTER using abapGit by creating a new online repository for https://github.com/abapPM/ABAP-Syntax-Highlighter
.
Recommended SAP package: $SYNTAX-HIGHLIGHTER
This project includes the code for the following open-source projects. Please support them if you can!
Made with ❤ in Canada
Copyright 2025 apm.to Inc. https://apm.to