# Pygments rather than highlight.js for syntax highlighting

**URL:** https://meta.discourse.org/t/pygments-rather-than-highlight-js-for-syntax-highlighting/391544
**Category:** Feature
**Tags:** code
**Created:** [17 december 2025 om 10:56 UTC](https://meta.discourse.org/t/pygments-rather-than-highlight-js-for-syntax-highlighting/391544 "2025-12-17T10:56:35Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![dbitouze](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@dbitouze](https://meta.discourse.org/u/dbitouze)
#### Post date: [17 december 2025 om 10:56 UTC](https://meta.discourse.org/t/pygments-rather-than-highlight-js-for-syntax-highlighting/391544/1 "2025-12-17T10:56:35Z")

</div>

For syntax highlighting, Discourse relies on `highlight.js` but [`Pygments`](https://pygments.org/) looks richer. For instance, here is how looks a Python code:

```python
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](https://pygments.org/demo/?lexer=python&style=dracula&formatter=html&code=text+%253D+input('Type+a+number%252C+and+its+factorial+will+be+printed%253A+')%0An+%253D+int(text)%0A%0Aif+n+%3C+0%253A%0A++++raise+ValueError('You+must+enter+a+non-negative+integer')%0A%0Afactorial+%253D+1%0Afor+i+in+range(2%252C+n+%252B+1)%253A%0A++++factorial+*%253D+i%0A%0Aprint(factorial)):

 ![image](https://global.discourse-cdn.com/meta/original/4X/0/f/a/0fa6202a1f7c575b04a60cfff43893211742b41d.png)

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:

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/0/f/20fe29eec0b319ec717e08e3cf7ffa2b208362f3.png)

to be compared with [how it could look with Pygments](https://pygments.org/demo/?lexer=&style=dracula&formatter=html&code=%5Cdocumentclass%5Bfrench%5D%7Barticle%7D%0A%5Cusepackage%5BT1%5D%7Bfontenc%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%5Cusepackage%7Blmodern%7D%0A%5Cusepackage%5Ba4paper%5D%7Bgeometry%7D%0A%5Cusepackage%7Bbabel%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cend%7Bdocument%7D):

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/e/1/8e1aad22c6a97b89ee27fad2b7b27d347e4d038b.png)

or even better with a customized theme/lexer:

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/b/c/2bca95dad16a3ddb3e0747d2ce98dabfd7034c35.png)

Would it be possible to rely on [`Pygments`](https://pygments.org/) rather than on `highlight.js`?

---

_[View the full topic](https://meta.discourse.org/t/pygments-rather-than-highlight-js-for-syntax-highlighting/391544)._
