Syntax Highlighting in Github Discussions #3016
Replies: 2 comments 6 replies
-
The Github Prolog syntax highlighting is very fragile in practice. See for example: example_term(
atom1, % Comment
atom2, % Another comment
atom3
). These are valid comments, but the syntax highlighting gets confused. At least it's better than nothing. For my editors I've had more luck with some tree-sitter based syntax highlighting, but there's the really unfortunate Prolog quirk that it's syntax is stateful because of operators. Tree-sitter grammars build an Concrete Syntax Tree of the code, and they can't be stateful. That means that if you use any operator that is unexpected for the grammar everything breaks down, and there's really no way to get around that. This is really unfortunate, because tree-sitter also allows some structural editing things that would fit Prolog really well. |
Beta Was this translation helpful? Give feedback.
-
I've been working on a tree-sitter grammar for ISO Prolog in part to overhaul emacs' prolog-mode to work better with Scryer, Trealla, and other ISO conformant systems. Github uses tree-sitter as you say, so.. could make a contribution there. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I see some of the masters have syntax highlighting in their discussion posts.
It works like this, using markdown syntax:
```prolog
parent(john, mary).
ancestor(X, Y) :- parent(X, Y).
```
which renders like:
In html, one case use code blocks and highlight.js:
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> <script>hljs.highlightAll();</script>`
`
Beta Was this translation helpful? Give feedback.
All reactions