1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-24 15:40:15 +01:00
mkdocs-material/docs/setup/extensions/python-markdown-extensions.md

4.2 KiB
Raw Blame History

template
overrides/main.html

Python Markdown Extensions

The Python Markdown Extensions package is an excellent collection of Markdown extensions that make technical writing a breeze. Material for MkDocs views this package as a sibling of its own, which is why most provided extensions are already natively supported.

Supported extensions

The following extensions are all supported by Material for MkDocs and therefore strongly recommended. See the overview page for a minimal and recommended configuration.

Arithmatex

:octicons-workflow-24: Extension · :octicons-tag-24: 1.0.0 present

The Arithmatex extension allows for rendering of block and inline equations, and integrates seamlessly with [MathJax]1, a library for mathematical typesetting. Enable it via mkdocs.yml:

markdown_extensions:
  - pymdownx.arithmatex:
      generic: true

Besides enabling the extension in mkdocs.yml, a MathJax configuration and the JavaScript runtime need to be included, which can be done with a few lines of additional JavaScript:

=== "docs/javascripts/config.js"

``` js
window.MathJax = {
  tex: {
    inlineMath: [["\\(", "\\)"]],
    displayMath: [["\\[", "\\]"]],
    processEscapes: true,
    processEnvironments: true
  },
  options: {
    ignoreHtmlClass: ".*|",
    processHtmlClass: "arithmatex"
  }
};

document$.subscribe(() => {
  MathJax.typesetPromise()
})
```

=== "mkdocs.yml"

``` yaml
extra_javascript:
  - javascripts/config.js
  - https://polyfill.io/v3/polyfill.min.js?features=es6
  - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
```

Arithmatex can be configured in many different ways, for which Material for MkDocs might not provide native support. See the Arithmatex documentation for more information.

Critic

:octicons-workflow-24: Extension · :octicons-tag-24: 1.0.0 present

The Critic extension allows for the usage of Critic Markup to highlight additions, deletions or substitutions in a Markdown documents. It can be enabled via mkdocs.yml:

markdown_extensions:
  - pymdownx.critic

The following configuration options are supported:

mode{ #mode }

:octicons-milestone-24: Default: view This option defines how the markup should be parsed, i.e. whether to just view all suggest changes, or alternatively accept or reject them:

=== "View changes"

``` yaml
markdown_extensions:
  - pymdownx.critic:
      mode: view
```

=== "Accept changes"

``` yaml
markdown_extensions:
  - pymdownx.critic:
      mode: accept
```

=== "Reject changes"

``` yaml
markdown_extensions:
  - pymdownx.critic:
      mode: reject
```

Details

The [Details] extension supercharges the [Admonition] extension, making the resulting call-outs collapsible, rendering

Emoji

Highlight

InlineHilite

Snippets

SuperFences

Tabbed

Tasklist

Other

  • Caret
  • Keys
  • MagicLink
  • Mark
  • SmartSymbols
  • Tilde

  1. Other libraries like KaTeX are also supported and can be integrated with some additional effort. See the Arithmatex documentation on KaTeX for further guidance, as this is beyond the scope of Material for MkDocs. ↩︎