An extension to python-markdown that replaces inline latex with prerendered SVGs
Project description
Markdown LaTeX Prerenderer
This is a very simple python-markdown extension, similar to other markdon-latex implementations that adds support for latex in markdown files.
The key differences to other approaches are:
- It does not require javascript on the client
- It does not require nodejs when building
For some reason, I could not find a way to render latex inside a markdown file without Javascript, that seemed crazy to me. So I built this tool. No KaTeX required. No NodeJS required. Just classic latex implementations.
How to use:
Make sure you have dvilualatex and dvisvgm installed on your system.
Then, add LatexExtension to your markdown extension list:
import markdown
from markdown_latex_prerender import LatexExtension
markdown.markdown(
md_str,
extensions=[
LatexExtension(),
...
],
)
How it works:
It uses the hosts dvilualatex and dvisvgm (both usually come with TexLive and friends) to convert a latex snippet to
an svg file. **It does not ship either program itself. This is why it's less that 200 lines of code.
Do not feed it untrusted input. It may break. Or worse.
Caching:
You may want to cache rendered things. For this, you can do something like this:
from my_fav_caching_library import cache_function
import markdown_latex_prerenderer.render as render
render.render_latex = cache_function(render.render_latex)
Or whatever else you feel like doing.
Inpiration:
Since I don't know how to build a python-markdown module to render inline-latex, I asked chatGPT looked at other
peoples solutions. I found this: arithmatex.py
in facelessuser/pymdown-extensions.
I re-used a lot of their code. I guess it works.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markdown_latex_prerender-0.1.1.tar.gz.
File metadata
- Download URL: markdown_latex_prerender-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
535e67bb5493c29859b39302cab7aae26960f9bf46718fcbc7ad9afe7c59ec5d
|
|
| MD5 |
1c0fe263368c7461943c2e78d4e510dc
|
|
| BLAKE2b-256 |
41ece1a8598f9684db7498aa92c8ccbbeea009f9d95b19cefc1c6820d13aa7d8
|
Provenance
The following attestation bundles were made for markdown_latex_prerender-0.1.1.tar.gz:
Publisher:
pythonpublish.yml on AntonLydike/markdown_latex_prerender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_latex_prerender-0.1.1.tar.gz -
Subject digest:
535e67bb5493c29859b39302cab7aae26960f9bf46718fcbc7ad9afe7c59ec5d - Sigstore transparency entry: 725411161
- Sigstore integration time:
-
Permalink:
AntonLydike/markdown_latex_prerender@2f1c505fcbd473b5b821ede46d6280c9ca52e47a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/AntonLydike
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pythonpublish.yml@2f1c505fcbd473b5b821ede46d6280c9ca52e47a -
Trigger Event:
release
-
Statement type:
File details
Details for the file markdown_latex_prerender-0.1.1-py3-none-any.whl.
File metadata
- Download URL: markdown_latex_prerender-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98a4aaed2da1f0f60cb09454d7fdf99e5c7d591099cc09fd55c7f205930b0e33
|
|
| MD5 |
f17736bb4a5906f78e9f28ef88ccf642
|
|
| BLAKE2b-256 |
956ba19306780ffe9bbd1b2c09415857f596118492063d293bb739aad5bd8e22
|
Provenance
The following attestation bundles were made for markdown_latex_prerender-0.1.1-py3-none-any.whl:
Publisher:
pythonpublish.yml on AntonLydike/markdown_latex_prerender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_latex_prerender-0.1.1-py3-none-any.whl -
Subject digest:
98a4aaed2da1f0f60cb09454d7fdf99e5c7d591099cc09fd55c7f205930b0e33 - Sigstore transparency entry: 725411167
- Sigstore integration time:
-
Permalink:
AntonLydike/markdown_latex_prerender@2f1c505fcbd473b5b821ede46d6280c9ca52e47a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/AntonLydike
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pythonpublish.yml@2f1c505fcbd473b5b821ede46d6280c9ca52e47a -
Trigger Event:
release
-
Statement type: