katex extension for Python Markdown
Project description
markdown-katex
This is an extension for Python Markdown which adds KaTeX support.
Project/Repo:
Code Quality/CI:
Name | role | since | until |
---|---|---|---|
Manuel Barkhau (mbarkhau@gmail.com) | author/maintainer | 2019-05 | - |
Install
$ pip install markdown-katex
This package includes the following binaries:
katex-cli-0.10.2-linux-x64
katex-cli-0.10.2-macos-x64
katex-cli-0.10.2-win-x64
If you are on a different platform, or want to use a more recent version of katex-cli
, you will need to install it via npm.
$ pip install katex
$ npx katex --version
0.10.2
This extension will always use the locally installed version of KaTeX if it is available, instead of using the implementation bundled with this package.
No JavaScript is required to render the resulting HTML, so it can be used with more limited renderers (which don't support JavaScript) such as WeasyPrint .
Usage
Formulas can be created and edited interactively using the editor on katex.org. They also have some good documentation for the subset of LaTeX that is supported. When embedding these in your Markdown files, they must be marked with a special syntax in order to be rendered using KaTeX. There are many syntax extensions for Markdown that allow LaTeX formulas to be embedded, however this package only supports the syntax introduced by Gitlab:
- For inline mode formulas: $`...`$
- For display mode formulas: ```math
Here is an example that uses this syntax.
There are two main advantages of this syntax:
- Gitlab has an existing Markdown renderer that can be used without the need to download any software. This implementation also uses KaTeX, so the output should be exactly the same as this extension.
- The fallback behaviour of other Markdown renderers is to render the raw LaTeX as inline code or a code block. This means that they won't inadvertently parse a LaTeX formula as Markdown syntax.
Hopefully other renderers will also adopt support for this syntax as:
- Rendering is done in the browser using KaTeX so implementation effort and should be minimal.
- The false positive rate for existing Markdown documents is negligible (ie. existing alternate use of $` syntax is minimal to non-existent).
Development/Testing
$ git clone https://gitlab.com/mbarkhau/markdown-katex
$ cd markdown-katex
$ make install
$ make lint mypy test
MkDocs Integration
In your mkdocs.yml
add this to markdown_extensions.
markdown_extensions:
- markdown_katex:
no_inline_svg: True
Changelog for https://gitlab.com/mbarkhau/markdown-katex
v201907.0008-beta
- Fix: don't require typing package for py<35
v201905.0007-beta
- Fix: Parsing of inline code when using multiple backticks
v201905.0004-beta
- Fix: better error reporting
- Fix: cleanup temp dir
v201905.0002-alpha
- Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file markdown-katex-201908.9b0.tar.gz
.
File metadata
- Download URL: markdown-katex-201908.9b0.tar.gz
- Upload date:
- Size: 38.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 700f2f0557c150aa949c5069a64f1a23908a73831732157c338a51d07eb5e7e3 |
|
MD5 | 08f43f278182cf9e7d44ead2c7872085 |
|
BLAKE2b-256 | 6c0da60a436f3f63dfc4801b424c157d07d8c098dcc93325b05a16e050bb6510 |
File details
Details for the file markdown_katex-201908.9b0-py2.py3-none-any.whl
.
File metadata
- Download URL: markdown_katex-201908.9b0-py2.py3-none-any.whl
- Upload date:
- Size: 39.1 MB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b60f9968fe4fcf7383a48b71683135ec085de05cfaddc579f16c70b2e798b58d |
|
MD5 | f896cd2277214ea5dd4664696e3c63ed |
|
BLAKE2b-256 | c482b593f3965f09d008469df0210205b4121eb2fafaf7cbefd7cb275a53671c |