tangle-md2tex
Extract LaTeX fenced code blocks from literate Markdown files.
中文文档见 README.zh-CN.md.
What It Does
tangle-md2tex reads Markdown files ending in .lit.md, extracts fenced code blocks whose info string is exactly latex, and writes the extracted LaTeX to a sibling .tex file.
For example:
```latex
First paragraph.
Second paragraph.
```
This prose explains why the LaTeX above is written this way.
becomes:
First paragraph.
Second paragraph.
Literate Markdown Format
Use .lit.md as the source file extension:
paper.lit.md -> paper.tex
sections/intro.lit.md -> sections/intro.tex
Only latex fenced code blocks are extracted:
```latex
\section{Introduction}
This is the manuscript text.
```
Explanation, notes, outlines, TODOs, or review comments can live here. They are
not copied into the generated `.tex` file.
Fence contents are copied as-is from markdown-it-py's token content. Leading
blank lines, paragraph-separating blank lines, and trailing blank lines inside a
latex fence are preserved because LaTeX uses blank lines to separate
paragraphs.
Install
pip install tangle-md2tex
For local development:
python -m pip install -e .
Usage
Process one file:
tanglemd2tex paper.lit.md
Process every .lit.md file under a directory:
tanglemd2tex sections/
If no path is given, the current directory is scanned recursively:
tanglemd2tex
You can also run it as a module:
python -m tanglemd2tex paper.lit.md
Python API
from pathlib import Path
from tanglemd2tex import tangle_file, tangle_text
tex_text = tangle_text(markdown_text)
tex_path = tangle_file(Path("paper.lit.md"))
Rules
- Source files must end with
.lit.md. - Output files are written next to the source file with the
.texextension. - Only fenced code blocks with info string
latexare extracted. - Non-LaTeX Markdown prose is treated as explanation and ignored by the output.
- The tool does not parse or validate LaTeX.
License
MIT
Metadata
Release files for tangle-md2tex 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tangle_md2tex-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / tangle_md2tex-0.2.0-py3-none-any.whl
| Download URL | tangle_md2tex-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ee19ec786a551a599b4198751af70068738c90644d4c06b983b107869d771ee
|
|
BLAKE2b-256 checksum How to use checksums |
8555daba75d2d50be59679d3b8ec2d97ef78979b3bf8d1e203a4116c2504bc7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for tangle-md2tex 0.2.0
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.