Highly customizable extensions for Python-Markdown in the style of LaTeX environments/theorems
Project description
Python-Markdown Environments
Replicating amsthm features and syntax in Markdown so you can publish mathematical papers in HTML—because what mathematician hasn't tried to publish in the very reputable journal called Their Janky Flask Personal Site That No One Will Ever See?
This Python-Markdown extension uses LaTeX-like syntax
\begin{...}
...
\end{...}
to create environments such as captioned figures, general-purpose <div>s, dropdowns, and user-defined LaTeX-style theorems that can be styled with attached HTML classes.
Installation
pip install markdown-environments
Available Environments
\begin{captioned_figure}: figures with captions\begin{cited_blockquote}: blockquotes with quote attribution- User-defined environments wrapped in general-purpose
<div>s to style to your heart's content - User-defined environments formatted as
<details>and<summary>dropdowns - User-defined LaTeX theorem environments with customizable:
- Theorem counters
- Heading punctuation
- Linkable
ids by theorem name
Documentation
Full documentation/API reference can be found here.
Example Usage
Backend:
import markdown
from markdown_environments import ThmsExtension
input_text = ...
output_text = markdown.markdown(input_text, extensions=[
ThmsExtension(
div_config={
"types": {
"thm": {
"thm_type": "Theorem",
"html_class": "md-thm",
"thm_counter_incr": "0,0,1"
},
r"thm\\\*": {
"thm_type": "Theorem",
"html_class": "md-thm"
}
},
"html_class": "md-div"
},
dropdown_config={
"types": {
"exer": {
"thm_type": "Exercise",
"html_class": "md-exer",
"thm_counter_incr": "0,0,1"
},
"pf": {
"thm_type": "Proof",
"thm_counter_incr": "0,0,0,1",
"thm_name_overrides_thm_heading": True
}
},
"html_class": "md-dropdown",
"summary_html_class": "md-dropdown__summary mb-0"
},
thm_heading_config={
"html_class": "md-thm-heading",
"emph_html_class": "md-thm-heading__emph"
}
)
])
Markdown input:
# Section {{1}}: this is theorem counter syntax from ThmsExtension()
## Subsection {{0,1}}: Bees
Here we begin our study of bees.
\begin{thm}[the bee theorem]
According to all known laws of aviation, there is no way that a bee should be able to fly.
\end{thm}
\begin{pf}
Its wings are too small to get its fat little body off the ground.
\end{pf}
\begin{thm\*}{hidden thm name used as `id`; not real LaTeX syntax}
Bees, of course, fly anyways.
\end{thm\*}
\begin{pf}[Proofs are configured to have titles override the heading]{hidden names are useless when there's already a name}
Because bees don't care what humans think is impossible.
\end{pf}
\begin{exer}
\begin{summary}
Prove that this `summary` environment is common to all dropdown-based environments.
\end{summary}
Solution: by reading the documentation, of course!
\end{exer}
\begin{exer}
All dropdowns initialized in `ThmsExtension()` have a default `summary` value of `thm_type`,
so using dropdowns like `pf` and `exer` here without a `summary` block is also fine.
\end{exer}
HTML output (prettified):
<h1>Section 1: this is theorem counter syntax from ThmsExtension()</h1>
<h2>Subsection 1.1: Bees</h2>
<p>Here we begin our study of bees.</p>
<div class="md-div md-thm">
<p>
<span class="md-thm-heading" id="the-bee-theorem">
<span class="md-thm-heading__emph">Theorem 1.1.1</span> (the bee theorem)<span class="md-thm-heading__emph">.</span>
</span>
According to all known laws of aviation, there is no way that a bee should be able to fly.
</p>
</div>
<details class="md-dropdown">
<summary class="md-dropdown__summary mb-0">
<span class="md-thm-heading">
<span class="md-thm-heading__emph">Proof 1.1.1.1</span><span class="md-thm-heading__emph">.</span>
</span>
</summary>
<div>
<p>Its wings are too small to get its fat little body off the ground.</p>
</div>
</details>
<div class="md-div md-thm">
<p>
<span class="md-thm-heading" id="hidden-thm-name-used-as-id-not-real-latex-syntax">
<span class="md-thm-heading__emph">Theorem</span><span class="md-thm-heading__emph">.</span>
</span>
Bees, of course, fly anyways.
</p>
</div>
<details class="md-dropdown">
<summary class="md-dropdown__summary mb-0">
<span class="md-thm-heading" id="proofs-are-configured-to-have-titles-override-the-heading">
<span class="md-thm-heading__emph">Proofs are configured to have titles override the heading</span><span class="md-thm-heading__emph">.</span>
</span>
</summary>
<div>
<p>Because bees don't care what humans think is impossible.</p>
</div>
</details>
<details class="md-dropdown md-exer">
<summary class="md-dropdown__summary mb-0">
<p>
<span class="md-thm-heading">
<span class="md-thm-heading__emph">Exercise 1.1.2</span><span class="md-thm-heading__emph">.</span>
</span>
Prove that this <code>summary</code> environment is common to all dropdown-based environments.
</p>
</summary>
<div>
<p>Solution: by reading the documentation, of course!</p>
</div>
</details>
<details class="md-dropdown md-exer">
<summary class="md-dropdown__summary mb-0">
<span class="md-thm-heading">
<span class="md-thm-heading__emph">Exercise 1.1.3</span><span class="md-thm-heading__emph">.</span>
</span>
</summary>
<div>
<p>
All dropdowns initialized in <code>ThmsExtension()</code> have a default <code>summary</code> value of <code>thm_type</code>,
so using dropdowns like <code>pf</code> and <code>exer</code> here without a <code>summary</code> block is also fine.
</p>
</div>
</details>
HTML example render:
Closed dropdowns:
Open dropdowns:
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_environments-1.10.1.tar.gz.
File metadata
- Download URL: markdown_environments-1.10.1.tar.gz
- Upload date:
- Size: 39.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bf352985b26e141884d63eeeec680c0a87532ceaef0e03cf8c2965d0e231fa5
|
|
| MD5 |
37333d76b9f6402df99bb7cdf10c55bc
|
|
| BLAKE2b-256 |
ad5a32978d2236f4a0b733ff078e67e2b632a379a2fc9de874f842b164d90ebd
|
Provenance
The following attestation bundles were made for markdown_environments-1.10.1.tar.gz:
Publisher:
publish.yaml on AnonymousRand/python_markdown_environments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_environments-1.10.1.tar.gz -
Subject digest:
9bf352985b26e141884d63eeeec680c0a87532ceaef0e03cf8c2965d0e231fa5 - Sigstore transparency entry: 1237573541
- Sigstore integration time:
-
Permalink:
AnonymousRand/python_markdown_environments@500c6a1974b09e4bd7ee29d108238d2fcf8ff017 -
Branch / Tag:
refs/tags/v1.10.1 - Owner: https://github.com/AnonymousRand
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@500c6a1974b09e4bd7ee29d108238d2fcf8ff017 -
Trigger Event:
release
-
Statement type:
File details
Details for the file markdown_environments-1.10.1-py3-none-any.whl.
File metadata
- Download URL: markdown_environments-1.10.1-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b34fe6221fe8cf5de6fb9cf70ecf955728308fab9aa1316ac05712b2213ace99
|
|
| MD5 |
02b6a509c75dfb90c203ecd069409391
|
|
| BLAKE2b-256 |
adf0c8e7edfb1621399da13cf5eaf98ec1c48541822c834f8438ea2b04686faf
|
Provenance
The following attestation bundles were made for markdown_environments-1.10.1-py3-none-any.whl:
Publisher:
publish.yaml on AnonymousRand/python_markdown_environments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_environments-1.10.1-py3-none-any.whl -
Subject digest:
b34fe6221fe8cf5de6fb9cf70ecf955728308fab9aa1316ac05712b2213ace99 - Sigstore transparency entry: 1237573579
- Sigstore integration time:
-
Permalink:
AnonymousRand/python_markdown_environments@500c6a1974b09e4bd7ee29d108238d2fcf8ff017 -
Branch / Tag:
refs/tags/v1.10.1 - Owner: https://github.com/AnonymousRand
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@500c6a1974b09e4bd7ee29d108238d2fcf8ff017 -
Trigger Event:
release
-
Statement type: