Pygments rather than highlight.js for syntax highlighting

For syntax highlighting, Discourse relies on highlight.js but Pygments looks richer. For instance, here is how looks a Python code:

text = input('Type a number, and its factorial will be printed: ')
n = int(text)

if n < 0:
    raise ValueError('You must enter a non-negative integer')

factorial = 1
for i in range(2, n + 1):
    factorial *= i

print(factorial)

to be compared with how it could look with Pygments:

This is more prominent for a LaTeX code block (unfortunately, this language is not enabled on the present forum) but here is how it looks on our Discourse forum:

to be compared with how it could look with Pygments:

or even better with a customized theme/lexer:

Would it be possible to rely on Pygments rather than on highlight.js?

The problem is, it’s a Python package and not a Javascript one :eyes: . I wonder if it can be converted over :thinking: .

2 לייקים

Ah, indeed, Pygments looks to be suitable for static html sites, not for applications such as Discourse.