question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

highlight.js vs CodeHilite & Pygments

See original GitHub issue

Description

Why bothering with CodeHilite and Pygments when mkdocs officialy and natively supports the much better highlight.js?

See https://www.mkdocs.org/user-guide/styling-your-docs/#mkdocs

Expected behavior

Syntax highlight works out of the box thanks to highlight.js

Actual behavior

Syntax highlight is not working because it requires CodeHilite marodwn extension to be enabled and Pygments python dependency to be installed.

See https://squidfunk.github.io/mkdocs-material/extensions/codehilite

Steps to reproduce the bug

Not relevant.

Package versions

  • Python: python --version: Python 3.7.3
  • MkDocs: mkdocs --version: mkdocs, version 1.0.4 from /usr/lib/python3.7/site-packages/mkdocs (Python 3.7)
  • Material: pip show mkdocs-material | grep -E ^Version: Version: 4.4.0

Project configuration

Not relevant.

System information

  • OS: ArchLinux
  • Browser: Firefox

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
facelessusercommented, Jul 24, 2019
2reactions
facelessusercommented, Jul 24, 2019

supports the much better highlight.js

This is a subjective statement. This is simply a matter of preference.

mkdocs officialy and natively supports

The official mkdocs theme official supports it. Mkdocs itself doesn’t particularly care what you use.

Highlight.js will pick up on language declarations assuming assume they are specified, which would require you to use CodeHilite even if you don’t want to use Pygments. Unless you really only on highlight.js guessing, which can be hit or miss.

It’s not too hard to configure CodeHilite to not use Pygments and then include highlight.js via the Mkdocs extra_js option.

Ultimately, it is the theme’s choice what to support our of the box. But there is nothing stopping people from using highlight.js.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CodeHilite — Python-Markdown 3.4.1 documentation
The CodeHilite extension adds code/syntax highlighting to standard Python-Markdown code blocks using Pygments. This extension is included in the standard ...
Read more >
Python-Markdown/markdown/extensions/codehilite.py
codehilite.py ... Determine language of source code, and pass it on to the Pygments ... just escape and build markup usable by JS...
Read more >
Syntax Highlighting | Hugo
Highlighting is carried out via the built-in highlight shortcode. It takes exactly one required parameter for the programming language to be highlighted and ......
Read more >
Code blocks - HPC & AI cluster
Default: true – This option allows to control whether highlighting should be carried out during build time by Pygments or runtime with a...
Read more >
extensions/codehilite.py · hemamaps/Markdown - Gemfury
Learn more » Push, build, and install RubyGems npm packages Python ... try: from pygments import highlight from pygments.lexers import get_lexer_by_name, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found