mkdocs-material/docs/reference/formatting.md
2021-10-04 23:36:31 +02:00

3.2 KiB

template
overrides/main.html

Formatting

Material for MkDocs provides support for several HTML elements that can be used to highlight sections of a document or apply specific formatting. Additionally, Critic Markup is supported, adding the ability to display suggested changes for a document.

Configuration

This configuration enables support for keyboard keys, highlighting changes to documents, highlighting text and defining sub- and superscript. Add the following lines to mkdocs.yml:

markdown_extensions:
  - pymdownx.critic
  - pymdownx.caret
  - pymdownx.keys
  - pymdownx.mark
  - pymdownx.tilde

Usage

Highlighting changes

When Critic is enabled, Critic Markup can be used, which adds the ability to highlight suggested changes, as well as add inline comments to a document.

Example:

Text can be {--deleted--} and replacement text {++added++}. This can also be
combined into {~~one~>a single~~} operation. {==Highlighting==} is also
possible {>>and comments can be added inline<<}.

{==

Formatting can also be applied to blocks by putting the opening and closing
tags on separate lines and adding new lines between the tags and the content.

==}

Result:

Text can be deleted and replacement text added. This can also be combined into onea single operation. Highlighting is also possible and comments can be added inline.

Formatting can also be applied to blocks by putting the opening and closing tags on separate lines and adding new lines between the tags and the content.

Highlighting text

When Caret, Mark & Tilde are enabled, text can be highlighted with a simple syntax, which is more convenient that directly using the corresponding mark, ins and del HTML tags.

Example:

- ==This was marked==
- ^^This was inserted^^
- ~~This was deleted~~

Result:

  • ==This was marked==
  • ^^This was inserted^^
  • This was deleted

Sub- and superscripts

When Caret & Tilde are enabled, text can be sub- and superscripted with a simple syntax, which is more convenient that directly using the corresponding sub and sup HTML tags:

Example:

- H~2~0
- A^T^A

Result:

  • H~2~0
  • A^T^A

Adding keyboard keys

When Keys is enabled, keyboard keys can be rendered with a simple syntax. Consult the Python Markdown Extensions documentation to learn about all available shortcodes.

Example:

++ctrl+alt+del++

Result:

++ctrl+alt+del++