Blog of Raivo Laanemets

Stories about web development, consulting and personal computers.

Prolog highlighter for highlight.js

On 2015-05-18

highlight.js is a JavaScript-based syntax highlighter (good for processing snippets in a browser!). For a long time it did not support Prolog syntax but the last release (8.5) has it now. Writing the initial code for the Prolog highlighter was quite straightforward but the language relevancy detection did not work well at first (some false positives) and required some tuning. However, it got resolved and the Prolog highlighter is now merged.

Example code:

append([],L,L).
append([H|T],L2,[H|L3]):-
    append(T,L2,L3).

% A comment.

:- append(['hello', ' '], ['world'], List), writeln(List).

If you have JavaScript enabled in the browser then you should see the snippet highlighted in colors.