pandoc-displaymath2equation
Replace blocks of displaymath with the equation environment, and enable links to labeled equations.
This is a very simple filter. For a solution with all the bells and whistles use the (now seemingly unmaintained) pandoc-eqnos.
Usage
Install the pandoc-displaymath2equation package from PyPI, and add pandoc-displaymath2equation to your filters.
python -m pip install pandoc-displaymath2equation
pandoc --filter pandoc-displaymath2equation path/to/file.md -o file.pdf
Display Math Conversion
Content that would usually generate output like this:
\[
1 + 1 = 2
\]
will instead generate a block like this:
\begin{equation}
1 + 1 = 2
\end{equation}
Referencing Labelled Equations
To reference an equation labeled id, use a string of the form (eq:id).
This will be replaced with \eqref{id}.
To label an equation, just use \label{id} in the display math block.
$$
E = mc^2 \label{important}
$$
With the default eq-ref option, this can be referenced in the text by using (eq:important).
Options
Options can be passed via document metadata.
| Key | Type | Default | Effect |
|---|---|---|---|
labeled-only |
bool |
false |
Do not transform blocks without a \label. |
eq-ref |
str |
\(eq:(?P<eq_id>[^)]+)\) |
Regex to match equation references. Can't match spaces. |
env-start |
str |
\begin{equation} |
Environment opening statement. |
env-stop |
str |
\end{equation} |
Environment closing statement. |
Development
Source-code goes into displaymath2equation/, tests go into tst/.
Code style should conform to PEP-8, and commit messages should follow the conventional commits spec.
Dependencies
Dependencies for development can be installed from requirements-dev.txt.
New dependencies should go into pyproject.toml.
If code in displaymath2equation/ depends on them, they go into [project.dependencies], otherwise into an environment in [project.optional-dependencies], most likely dev.
If dependencies are added, requirements.txt and requirements-dev.txt should be regenerated.
This can be done with make requirements.txt and make requirements-dev.txt respectively.
Testing
Having tests is nice. Even though the test we have is a little sparse, it's better than no test.
Docs
Documentation is nice, but doesn't exist yet.
Once it does, it goes into docs.
TODOs
Possible future features that would be nice to have:
- syntax for determining the text/mark/number rendered next to the equation
- logic to deal with split/align environments
Metadata
Release files for pandoc-displaymath2equation 0.0.0.3
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 |
|---|---|---|---|---|
| pandoc_displaymath2equation-0.0.0.3.tar.gz | 5.6 kB | Without provenance | Details for pandoc_displaymath2equation-0.0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandoc_displaymath2equation-0.0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pandoc_displaymath2equation-0.0.0.3-py3-none-any.whl |
Total release size: 11.5 kB
Release files / pandoc_displaymath2equation-0.0.0.3.tar.gz
| Download URL | pandoc_displaymath2equation-0.0.0.3.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecc21a825035c993167c99d5c0d1d591c017daf81b08aa8f3bddf1a9454e4f99
|
|
BLAKE2b-256 checksum How to use checksums |
476bc44432096ad0bdb6c0333823ef8fa27781c8f3a1a158fcae79f945debf4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / pandoc_displaymath2equation-0.0.0.3-py3-none-any.whl
| Download URL | pandoc_displaymath2equation-0.0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4c2502dc233d3d7077d96c3350476a0fe9fe4f2b3638f9d37f2168af28b813f
|
|
BLAKE2b-256 checksum How to use checksums |
adbe3de3f401bd605e6ecb27b85b8578a7af98c875e302dfd5db450639d129f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for pandoc-displaymath2equation 0.0.0.3
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.