markdown_math_escape
Python-Markdown extension to escape math
expressions like $e^{i\pi} + 1 = 0$.
Description
The benefits of using this extension are:
- No special escaping syntax is needed
- You can write
\left\{, not\left\\{.
- You can write
- On writing, you are free to choose any delimiter style as you like
- It's fast
- This extension does not render mathematics
On the other hand:
- You need to setup either MathJax or KaTeX for client-side rendering
- If you are using Nikola, you can use it's built-in feature to enable them
- Otherwise, somehow you need to load and execute one of them (using a theme which supports them, for example)
Technically, this extension firstly protects math expressions from Python-Markdown and its other extensions so that no unexpected (unhappy) change will happen. Then it converts their delimiters (enclosing special characters) to "brackets" styled delimiters... which is supported by default configuration of MathJax and KaTeX.
Installation
Firstly, install the extension by the command below:
pip install markdown_math_escape
Secondly, you need to let Python-Markdown to use it. How to do it depends on how you are using Python-Markdown. Please see examples for an example which matches your usage.
Options
The only available option is "delimiters" which specifies the type of
delimiters enclosing mathematics in your markdown files.
See the table below for supported values.
delimiters |
Inline (non-display mode) | Display mode math |
|---|---|---|
dollers |
$e^{i\pi} + 1 = 0$ |
$$
e^{i\pi} + 1 = 0
$$ |
brackets |
\(e^{i\pi} + 1 = 0\) |
\[
e^{i\pi} + 1 = 0
\] |
gitlab |
$`e^{i\pi} + 1 = 0`$ |
```math
e^{i\pi} + 1 = 0
``` |
Examples
Python script
If you are using Python-Markdown directly in your Python script (or library), just do so in the standard way. For example:
import markdown as md
from markdown_math_escape import MathEscapeExtension
md.markdown(
some_text,
extensions=[
"markdown.extensions.codehilite",
"markdown.extensions.extra",
MathEscapeExtension(delimiters="dollers"),
],
)
Please refer to the Python-Markdown's document for more details.
Pelican
If you are using Python-Markdown as part of
Pelican,
you can use extension name markdown_math_escape. For example:
# pelicanconf.py
MARKDOWN = {
'extension_configs': {
# ...other extensions...
"markdown_math_escape": {"delimiters": "dollers"},
}
}
Please refer to the Pelican's document for more details.
Nikola
If you are using Python-Markdown as part of
Nikola,
you can use extension name markdown_math_escape. For example:
# conf.py
MARKDOWN_EXTENSIONS = [
# ...other extensions...
'markdown_math_escape',
]
MARKDOWN_EXTENSION_CONFIGS = {
DEFAULT_LANG: {
"markdown_math_escape": {"delimiters": "dollers"},
},
}
Note that this extension is compatible with Nikola's built-in option to enable
MathJax or KaTeX. Just set
has_math metadata field in your post to true and select MathJax or KaTeX by
specifying USE_KATEX value in conf.py.
Metadata
Release files for markdown-math-escape 0.20.12.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| markdown_math_escape-0.20.12.17.tar.gz | 6.2 kB | Without provenance | Details for markdown_math_escape-0.20.12.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| markdown_math_escape-0.20.12.17-py3-none-any.whl | Python 3 | none | any | Details for markdown_math_escape-0.20.12.17-py3-none-any.whl |
Total release size: 12.9 kB
Release files / markdown_math_escape-0.20.12.17.tar.gz
| Download URL | markdown_math_escape-0.20.12.17.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c83b126e8c7cacd08afc74b14003ba57127bec5fe026909b896ade571a87f1a5
|
|
BLAKE2b-256 checksum How to use checksums |
023be5f68c2f550ea8e0ea5385ffdc0f314fd5d4578159075744e9fc138af13d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
|
Release files / markdown_math_escape-0.20.12.17-py3-none-any.whl
| Download URL | markdown_math_escape-0.20.12.17-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7878b9461bc792860912f9c7970a51230863164c340e44d8afeddb5b044adbfb
|
|
BLAKE2b-256 checksum How to use checksums |
8a6938abf7223929d0fb3f33969e61787bafe4f89ce094aabed25f135097a553
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
|
Security for markdown-math-escape 0.20.12.17
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.