2016-12-27 14:26:25 +03:00
|
|
|
|
# PyMdown Extensions
|
|
|
|
|
|
|
|
|
|
[PyMdown Extensions][1] is a collection of Markdown extensions that add some
|
|
|
|
|
great features to the standard Markdown library. For this reason, the
|
|
|
|
|
**installation of this package is highly recommended** as it's well-integrated
|
|
|
|
|
with the Material theme.
|
|
|
|
|
|
2019-11-29 18:52:08 +03:00
|
|
|
|
[1]: https://facelessuser.github.io/pymdown-extensions/
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
The PyMdown Extensions package can be installed with the following command:
|
|
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
|
pip install pymdown-extensions
|
|
|
|
|
```
|
|
|
|
|
|
2017-01-07 22:07:41 +03:00
|
|
|
|
The following list of extensions that are part of the PyMdown Extensions
|
|
|
|
|
package are recommended to be used together with the Material theme:
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
2017-01-09 23:41:30 +03:00
|
|
|
|
- pymdownx.arithmatex
|
2017-10-16 20:13:05 +03:00
|
|
|
|
- pymdownx.betterem:
|
|
|
|
|
smart_enable: all
|
2016-12-27 14:26:25 +03:00
|
|
|
|
- pymdownx.caret
|
|
|
|
|
- pymdownx.critic
|
2017-08-29 09:17:26 +03:00
|
|
|
|
- pymdownx.details
|
2017-01-10 00:25:15 +03:00
|
|
|
|
- pymdownx.emoji:
|
|
|
|
|
emoji_generator: !!python/name:pymdownx.emoji.to_svg
|
2016-12-27 14:26:25 +03:00
|
|
|
|
- pymdownx.inlinehilite
|
|
|
|
|
- pymdownx.magiclink
|
|
|
|
|
- pymdownx.mark
|
|
|
|
|
- pymdownx.smartsymbols
|
|
|
|
|
- pymdownx.superfences
|
2017-10-16 20:13:05 +03:00
|
|
|
|
- pymdownx.tasklist:
|
|
|
|
|
custom_checkbox: true
|
2020-02-14 10:16:04 +03:00
|
|
|
|
- pymdownx.tabbed
|
2016-12-27 14:26:25 +03:00
|
|
|
|
- pymdownx.tilde
|
|
|
|
|
```
|
|
|
|
|
|
2017-01-03 01:11:32 +03:00
|
|
|
|
## Usage
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
2017-01-09 23:41:30 +03:00
|
|
|
|
### Arithmatex <small>MathJax</small>
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
2017-05-11 04:58:47 +03:00
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
2017-08-29 14:46:07 +03:00
|
|
|
|
[Arithmatex][2] integrates Material with [MathJax][3] which parses
|
2016-12-27 14:26:25 +03:00
|
|
|
|
block-style and inline equations written in TeX markup and outputs them in
|
2017-08-29 14:46:07 +03:00
|
|
|
|
mathematical notation. See [this thread][4] for a short introduction and quick
|
2016-12-27 14:26:25 +03:00
|
|
|
|
reference on how to write equations in TeX syntax.
|
|
|
|
|
|
2017-01-09 23:41:30 +03:00
|
|
|
|
Besides activating the extension in the `mkdocs.yml`, the MathJax JavaScript
|
2017-01-12 22:15:30 +03:00
|
|
|
|
runtime needs to be included. This must be done with
|
2017-08-29 14:46:07 +03:00
|
|
|
|
[additional JavaScript][5]:
|
2017-01-09 23:41:30 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
2017-01-09 23:52:04 +03:00
|
|
|
|
extra_javascript:
|
2017-05-11 04:58:47 +03:00
|
|
|
|
- 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'
|
2017-01-09 23:41:30 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
If you want to override the default MathJax configuration, you can do this by
|
2017-01-09 23:52:04 +03:00
|
|
|
|
adding another JavaScript file **before** the MathJax runtime in
|
|
|
|
|
`extra_javascript` which contains your MathJax configuration, e.g.:
|
2017-01-09 23:41:30 +03:00
|
|
|
|
|
|
|
|
|
``` js
|
2017-01-09 23:58:29 +03:00
|
|
|
|
window.MathJax = {
|
|
|
|
|
tex2jax: {
|
|
|
|
|
inlineMath: [ ["\\(","\\)"] ],
|
|
|
|
|
displayMath: [ ["\\[","\\]"] ]
|
|
|
|
|
},
|
|
|
|
|
TeX: {
|
|
|
|
|
TagSide: "right",
|
|
|
|
|
TagIndent: ".8em",
|
|
|
|
|
MultLineWidth: "85%",
|
|
|
|
|
equationNumbers: {
|
|
|
|
|
autoNumber: "AMS",
|
|
|
|
|
},
|
|
|
|
|
unicode: {
|
|
|
|
|
fonts: "STIXGeneral,'Arial Unicode MS'"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
displayAlign: "left",
|
|
|
|
|
showProcessingMessages: false,
|
|
|
|
|
messageStyle: "none"
|
|
|
|
|
};
|
2017-01-09 23:41:30 +03:00
|
|
|
|
```
|
|
|
|
|
|
2017-01-09 23:52:04 +03:00
|
|
|
|
In your `mkdocs.yml`, include it with:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
extra_javascript:
|
2017-01-12 22:15:30 +03:00
|
|
|
|
- 'javascripts/extra.js'
|
2017-05-11 04:58:47 +03:00
|
|
|
|
- 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'
|
2017-01-09 23:52:04 +03:00
|
|
|
|
```
|
|
|
|
|
|
2017-08-29 14:46:07 +03:00
|
|
|
|
[2]: https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex/
|
|
|
|
|
[3]: https://www.mathjax.org/
|
2019-11-29 18:52:08 +03:00
|
|
|
|
[4]: https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference
|
2017-08-29 14:46:07 +03:00
|
|
|
|
[5]: ../customization.md#additional-javascript
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
2017-01-09 23:41:30 +03:00
|
|
|
|
#### Blocks
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
|
|
|
|
Blocks are enclosed in `:::tex $$...$$` which are placed on separate lines.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
``` tex
|
|
|
|
|
$$
|
|
|
|
|
\frac{n!}{k!(n-k)!} = \binom{n}{k}
|
|
|
|
|
$$
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Result:
|
|
|
|
|
|
|
|
|
|
$$
|
|
|
|
|
\frac{n!}{k!(n-k)!} = \binom{n}{k}
|
|
|
|
|
$$
|
|
|
|
|
|
2017-01-09 23:41:30 +03:00
|
|
|
|
#### Inline
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
|
|
|
|
Inline equations need to be enclosed in `:::tex $...$`:
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
``` tex
|
|
|
|
|
Lorem ipsum dolor sit amet: $p(x|y) = \frac{p(y|x)p(x)}{p(y)}$
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Result:
|
|
|
|
|
|
|
|
|
|
Lorem ipsum dolor sit amet: $p(x|y) = \frac{p(y|x)p(x)}{p(y)}$
|
|
|
|
|
|
2017-08-29 14:46:07 +03:00
|
|
|
|
### BetterEm
|
|
|
|
|
|
|
|
|
|
[BetterEm][6] improves the handling of emphasis markup (**bold** and *italic*)
|
|
|
|
|
within Markdown by providing a more sophisticated parser for better detecting
|
|
|
|
|
start and end tokens. Read the documentation for [usage notes][7].
|
|
|
|
|
|
|
|
|
|
[6]: https://facelessuser.github.io/pymdown-extensions/extensions/betterem/
|
|
|
|
|
[7]: https://facelessuser.github.io/pymdown-extensions/usage_notes/
|
|
|
|
|
|
|
|
|
|
### Caret
|
|
|
|
|
|
|
|
|
|
[Caret][8] makes it possible to highlight ^^inserted text^^. The portion of
|
|
|
|
|
text that should be marked as added must be enclosed in two carets `^^...^^`.
|
|
|
|
|
|
|
|
|
|
[8]: https://facelessuser.github.io/pymdown-extensions/extensions/caret/
|
|
|
|
|
|
|
|
|
|
### Critic
|
|
|
|
|
|
|
|
|
|
[Critic][9] implements [Critic Markup][10], a Markdown extension that enables
|
|
|
|
|
the tracking of changes (additions, deletions and comments) on documents.
|
|
|
|
|
During compilation of the Markdown document, changes can be rendered (default),
|
|
|
|
|
accepted or rejected.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
==}
|
|
|
|
|
|
|
|
|
|
[9]: https://facelessuser.github.io/pymdown-extensions/extensions/critic/
|
|
|
|
|
[10]: http://criticmarkup.com/
|
|
|
|
|
|
|
|
|
|
### Details
|
|
|
|
|
|
|
|
|
|
[Details][11] adds collapsible [Admonition-style blocks][12] which can contain
|
|
|
|
|
arbitrary content using the HTML5 `details` and `summary` tags. Additionally,
|
2017-08-29 17:17:16 +03:00
|
|
|
|
all Admonition qualifiers can be used, e.g. `note`, `question`, `warning` etc.:
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
??? question "How many Prolog programmers does it take to change a lightbulb?"
|
|
|
|
|
|
|
|
|
|
Yes.
|
|
|
|
|
|
|
|
|
|
[11]: https://facelessuser.github.io/pymdown-extensions/extensions/details/
|
|
|
|
|
[12]: admonition.md
|
|
|
|
|
|
|
|
|
|
### Emoji
|
|
|
|
|
|
|
|
|
|
[Emoji][13] adds the ability to insert a :shit:-load of emojis that we use in
|
2019-11-16 22:47:02 +03:00
|
|
|
|
our daily lives.
|
|
|
|
|
|
|
|
|
|
By default, [Emoji][13] uses JoyPixles' emoji under the former name EmojiOne.
|
|
|
|
|
Recent versions of the extension lock support to an older version (2.2.7) due
|
|
|
|
|
to JoyPixels' newer, less permissible licenses included in later releases. This
|
|
|
|
|
restricts support to Unicode 9. To get the latest support for the current
|
|
|
|
|
Unicode version, you can use Twemoji instead which has a much more permissable
|
|
|
|
|
license. Simply override the default emoji index being used:
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- pymdownx.emoji:
|
|
|
|
|
emoji_index: !!python/name:pymdownx.emoji.twemoji
|
|
|
|
|
emoji_generator: !!python/name:pymdownx.emoji.to_svg
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To view all the available short names and emoji available, see [Emoji's documentation][18]
|
|
|
|
|
on your chosen index which includes links to the files containing the short names
|
|
|
|
|
and emoji associated with each supported index. Happy scrolling :tada:.
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
!!! warning "Legal disclaimer"
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
Material has no affiliation with [JoyPixles][15] or [Twemoji][14], both
|
|
|
|
|
of which use releases that are under [CC BY 4.0][16]. When including
|
|
|
|
|
images or CSS from either provider, please read the the respective
|
|
|
|
|
licenses: [EmojiOne][17] or [Twemoji][14] to ensure proper usage and
|
|
|
|
|
attribution.
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
[13]: https://facelessuser.github.io/pymdown-extensions/extensions/emoji/
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[14]: https://twemoji.twitter.com/
|
2019-11-06 19:50:52 +03:00
|
|
|
|
[15]: https://www.joypixels.com/
|
2017-08-29 14:46:07 +03:00
|
|
|
|
[16]: https://creativecommons.org/licenses/by/4.0/legalcode
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[17]: https://github.com/joypixels/emojione#emojione-version-2
|
|
|
|
|
[18]: https://facelessuser.github.io/pymdown-extensions/extensions/emoji/#default-emoji-indexes
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
2017-01-09 23:41:30 +03:00
|
|
|
|
### InlineHilite
|
2016-12-27 14:26:25 +03:00
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[InlineHilite][19] adds support for inline code highlighting. It's useful for
|
2016-12-27 14:26:25 +03:00
|
|
|
|
short snippets included within body copy, e.g. `#!js var test = 0;` and can be
|
2019-05-10 18:14:55 +03:00
|
|
|
|
achieved by prefixing inline code with a shebang and language identifier,
|
2016-12-27 14:26:25 +03:00
|
|
|
|
e.g. `#!js`.
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[19]: https://facelessuser.github.io/pymdown-extensions/extensions/inlinehilite/
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
### MagicLink
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[MagicLink][20] detects links in Markdown and auto-generates the necessary
|
2017-08-29 14:46:07 +03:00
|
|
|
|
markup, so no special syntax is required. It auto-links `http[s]://` and
|
|
|
|
|
`ftp://` links, as well as references to email addresses.
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[20]: https://facelessuser.github.io/pymdown-extensions/extensions/magiclink/
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
### Mark
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[Mark][21] adds the ability to ==highlight text== like it was marked with a
|
2017-08-29 14:46:07 +03:00
|
|
|
|
==text marker==. The portion of text that should be highlighted must be
|
|
|
|
|
enclosed in two equal signs `==...==`.
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[21]: https://facelessuser.github.io/pymdown-extensions/extensions/mark/
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
### SmartSymbols
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[SmartSymbols][22] converts markup for special characters into their
|
2017-08-29 14:46:07 +03:00
|
|
|
|
corresponding symbols, e.g. arrows (<--, -->, <-->), trademark and copyright
|
|
|
|
|
symbols ((c), (tm), (r)) and fractions (1/2, 1/4, ...).
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[22]: https://facelessuser.github.io/pymdown-extensions/extensions/smartsymbols/
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
### SuperFences
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[SuperFences][23] provides the ability to nest code blocks under blockquotes,
|
|
|
|
|
lists and other block elements, which the [Fenced Code Blocks][24] extension
|
2017-08-29 14:46:07 +03:00
|
|
|
|
from the standard Markdown library doesn't parse correctly.
|
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
SuperFences does also allow [grouping code blocks with tabs][25].
|
2018-06-10 19:06:45 +03:00
|
|
|
|
|
2019-11-16 22:47:02 +03:00
|
|
|
|
[23]: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/
|
|
|
|
|
[24]: https://python-markdown.github.io/extensions/fenced_code_blocks/
|
|
|
|
|
[25]: codehilite.md#grouping-code-blocks
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
2020-02-14 10:16:04 +03:00
|
|
|
|
### Tabbed
|
|
|
|
|
|
|
|
|
|
[Tabbed][26] adds support for creating tabbed groups of Markdown content.
|
|
|
|
|
|
|
|
|
|
``` markdown
|
|
|
|
|
=== "Fruit List"
|
|
|
|
|
- Apple
|
|
|
|
|
- Banana
|
|
|
|
|
- Orange
|
|
|
|
|
|
|
|
|
|
=== "Fruit Table"
|
|
|
|
|
Fruit | Color
|
|
|
|
|
------ | -----
|
|
|
|
|
Apple | Red
|
|
|
|
|
Banana | Yellow
|
|
|
|
|
Oragne | Orange
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "Fruit List"
|
|
|
|
|
- Apple
|
|
|
|
|
- Banana
|
|
|
|
|
- Orange
|
|
|
|
|
|
|
|
|
|
=== "Fruit Table"
|
|
|
|
|
Fruit | Color
|
|
|
|
|
------ | -----
|
|
|
|
|
Apple | Red
|
|
|
|
|
Banana | Yellow
|
|
|
|
|
Oragne | Orange
|
|
|
|
|
|
|
|
|
|
[26]: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/
|
|
|
|
|
|
2017-08-29 14:46:07 +03:00
|
|
|
|
### Tasklist
|
|
|
|
|
|
2020-02-14 10:16:04 +03:00
|
|
|
|
[Tasklist][27] adds support for styled checkbox lists. This is useful for
|
2017-08-29 14:46:07 +03:00
|
|
|
|
keeping track of tasks and showing what has been done and has yet to be done.
|
|
|
|
|
Checkbox lists are like regular lists, but prefixed with `[ ]` for empty or
|
|
|
|
|
`[x]` for filled checkboxes.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
``` markdown
|
|
|
|
|
* [x] Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
|
|
|
* [x] Nulla lobortis egestas semper
|
|
|
|
|
* [x] Curabitur elit nibh, euismod et ullamcorper at, iaculis feugiat est
|
|
|
|
|
* [ ] Vestibulum convallis sit amet nisi a tincidunt
|
|
|
|
|
* [x] In hac habitasse platea dictumst
|
|
|
|
|
* [x] In scelerisque nibh non dolor mollis congue sed et metus
|
|
|
|
|
* [x] Sed egestas felis quis elit dapibus, ac aliquet turpis mattis
|
|
|
|
|
* [ ] Praesent sed risus massa
|
|
|
|
|
* [ ] Aenean pretium efficitur erat, donec pharetra, ligula non scelerisque
|
|
|
|
|
* [ ] Nulla vel eros venenatis, imperdiet enim id, faucibus nisi
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Result:
|
|
|
|
|
|
|
|
|
|
* [x] Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
|
|
|
* [x] Nulla lobortis egestas semper
|
|
|
|
|
* [x] Curabitur elit nibh, euismod et ullamcorper at, iaculis feugiat est
|
|
|
|
|
* [ ] Vestibulum convallis sit amet nisi a tincidunt
|
|
|
|
|
* [x] In hac habitasse platea dictumst
|
|
|
|
|
* [x] In scelerisque nibh non dolor mollis congue sed et metus
|
|
|
|
|
* [x] Sed egestas felis quis elit dapibus, ac aliquet turpis mattis
|
|
|
|
|
* [ ] Praesent sed risus massa
|
|
|
|
|
* [ ] Aenean pretium efficitur erat, donec pharetra, ligula non scelerisque
|
|
|
|
|
* [ ] Nulla vel eros venenatis, imperdiet enim id, faucibus nisi
|
|
|
|
|
|
2020-02-14 10:16:04 +03:00
|
|
|
|
[27]: https://facelessuser.github.io/pymdown-extensions/extensions/tasklist/
|
2017-08-29 14:46:07 +03:00
|
|
|
|
|
|
|
|
|
### Tilde
|
|
|
|
|
|
2020-02-14 10:16:04 +03:00
|
|
|
|
[Tilde][28] provides an easy way to ~~strike through~~ cross out text.
|
2017-08-29 14:46:07 +03:00
|
|
|
|
The portion of text that should be erased must be enclosed in two tildes
|
|
|
|
|
`~~...~~` and the extension will take care of the rest.
|
|
|
|
|
|
2020-02-14 10:16:04 +03:00
|
|
|
|
[28]: https://facelessuser.github.io/pymdown-extensions/extensions/tilde/
|