• Reference

Syntax highlighting

To use syntax highlighting you need to enable the following extensions in your mkdocs.yml:

markdown_extensions:
  - pymdownx.inlinehilite
  - pymdownx.superfences

You can wrap inline code between backticks (`) to apply syntax highlighting. Example: `#!python print('Hello world')` will be rendered as print('Hello world').

You can also use Fenced Code Blocks, i.e., wrap multiline code between triple backticks (```). Example:

def func(arg1, arg2):
    """
    Docstrings
    """
    m = max(arg1, arg2)  # Some comment
    return m

if __name__=='__main__':
    print(func(21, 32))
```python
def func(arg1, arg2):
    """
    Docstrings
    """
    m = max(arg1, arg2)  # Some comment
    return m

if __name__=='__main__':
    print(func(21, 32))
```

You can also add line numbers:

1
2
3
4
5
6
7
8
9
def func(arg1, arg2):
    """
    Docstrings
    """
    m = max(arg1, arg2)  # Some comment
    return m

if __name__=='__main__':
    print(func(21, 32))
```python linenums="1"
def func(arg1, arg2):
    """
    Docstrings
    """
    m = max(arg1, arg2)  # Some comment
    return m

if __name__=='__main__':
    print(func(21, 32))
```