mkdocs-terminal with PyMdown and Pygments#

This example site uses the Pygments library and PyMdown Extensions to hilight code blocks as they are rendered to HTML during the MkDocs build process.

Please review the Pygments docs for more information on supported programming languages and available styles:

Set Up#

Install Pygments and PyMdown#

Install Pygments (minimum version 2.12) and PyMdown Extensions:

mkdocs
mkdocs-terminal~=4.0

# Python Markdown Extensions
pygments>=2.12
pymdown-extensions

Enable PyMdown Extensions#

Enable the pymdownx extensions according to the PyMdown documentation:

Note: for the configuration used in this example site, pymdownx.superfences must be enabled.

mkdocs.yml excerpt:

markdown_extensions:
  - pymdownx.superfences          # required extension
  - pymdownx.highlight:
      use_pygments: true          # use pygments library    
      pygments_style: github-dark # use 'github-dark' style
      noclasses: true             # update HTML style attr
  - pymdownx.inlinehilite         # style inline code

theme:
  name: terminal
  palette: dark