papis-make-epub
Build EPUB renditions of articles in your Papis library. Current sources include fetching arXiv's LaTeXML-generated HTML or using downloaded HTML pages from publishers' websites (see Sources). Math is often served as MathML, and sometimes as MathJax/LaTeX, which can optionally be rendered at build time for readers that don't render math themselves (see Math Rendering).
Installation
Install papis-make-epub in the same Python environment as papis, and
it registers the papis make-epub command as a plugin:
pip install papis-make-epub
Installed elsewhere, the package also works through papis's external
command mechanism: papis runs any papis-make-epub script found on
PATH as papis make-epub.
Some of the optional math renderers call external programs: node
with the mathjax-node library resolvable through NODE_PATH for
the mathjax renderer, lasem-render for the lasem renderer, and
the texmath executable whenever the selected renderer needs a
conversion between TeX and MathML (see
Math Rendering). Make sure the ones you use are
on PATH.
Nix
For Nix users, everything above comes as one package: papis with
the plugin and the renderers' programs on its PATH. Try it out
without installing:
nix run github:jabarszcz/papis-make-epub -- --help
To install, add the flake as an input to a NixOS or home-manager configuration:
inputs.papis-make-epub.url = "github:jabarszcz/papis-make-epub";
and install the package:
environment.systemPackages = [ # home.packages for home-manager
inputs.papis-make-epub.packages.${pkgs.system}.papis-with-make-epub
];
For other compositions (more plugins, only some of the programs),
adapt the recipe in nix/default.nix.
Without flakes, fetch the source and import nix/, which
composes the same wrapped papis:
let
papis-make-epub = fetchTarball
"https://github.com/jabarszcz/papis-make-epub/archive/main.tar.gz";
in {
environment.systemPackages = [ # home.packages for home-manager
(import "${papis-make-epub}/nix" { inherit pkgs; })
];
}
Basic Usage
1. Manually download the HTML page for the article
The article should already be in your Papis library. An arXiv paper needs no download: its HTML rendition is fetched at the next step. For the other sources, you'll first want to manually download the HTML page with the article contents, as headless downloads are often blocked: save it from the browser ("Save Page As, Web Page complete").
MathJax version 3 consumes the MathML when it runs, replacing it with its rendered output, so on a platform running it (sciencedirect.com currently) keep MathJax from running: block its script before loading the page (devtools → Network → right-click the mathjax request → "Block request URL", then reload).
To get a single file without the _files folder, capture with
SingleFile instead,
which the re-capture script also uses.
Disable its script blocking (under Network) to keep the TeX that
MathJax v2 leaves in <script> elements (IEEE Xplore, Springer).
2. Convert it to EPUB
Convert and add the EPUB to your Papis document, identified by a
query. The book's metadata comes from the document's info.yaml.
papis make-epub <query> saved-page.html
A page already among the document's files (e.g. added with
papis addto) is picked up automatically, and the HTML rendition
of the arXiv paper named by the metadata (eprint, or an
arxiv.org URL) is fetched, so both build without a file argument:
papis make-epub <query>
Sources
The EPUB is translated from a full-text HTML rendition served by
the article's publisher (not every article has one). We handle
each platform's markup in its own module under
papis_make_epub/sources/. The source is
automatically detected from the page markup, and the --from flag can
be used if ever that fails.
--from |
Sites | Math |
|---|---|---|
arxiv |
arxiv.org | MathML + TeX |
acm |
dl.acm.org (/doi/full/ page) |
MathML |
springer |
link.springer.com, nature.com | MathML + TeX |
ieee |
ieeexplore.ieee.org | TeX |
sciencedirect |
sciencedirect.com | MathML |
The Math column names what the page carries per formula: MathML, the TeX the platform serves for MathJax to render, or both. Math Rendering covers how either is rendered.
Potential future sources:
- running LaTeXML ourselves when a LaTeX version is available;
- doing OCR or VLMs/agentic extraction from PDFs.
Math Rendering
E-readers differ in what math they can display, so rendering can be
pre-baked (choose the renderer with the --math, --math-inline or
--math-display flags).
| Renderer | Consumes | Output | Program |
|---|---|---|---|
mathml |
MathML | MathML | none |
pylatexenc |
TeX | Unicode with sub/sup tags | none |
mathtext |
TeX | PNG (matplotlib) | none |
mathjax |
MathML or TeX | SVG | node (with mathjax-node) |
lasem |
MathML | PNG | lasem-render |
A source supplies each formula as TeX or MathML (the Math column
in the Sources table); a renderer consuming the other form needs
the texmath program, which converts each formula, and could
fail on some or be lossy.
The default renderer, mathml, passes the MathML through,
leaving the rendering to the reading device; every other renderer
trades something away (text flattens layout, images fix the font
and size). papis-make-epub-demo builds a comparison EPUB, one
section per renderer over identical formulas, for judging the
renderers on a device.
The build fails on the first formula the selected renderer
cannot render. With --best-effort it continues: rendering falls
back along mathjax/lasem → mathtext → pylatexenc → verbatim
from the selected renderer down.
Testing
Publisher pages change, and there is no simple check that an EPUB is the right rendition of a page; the suite therefore leans on characterization tests: goldens pin the current output, cheap to keep, at the cost of reviewing their diffs once in a while. epubcheck validates each built EPUB (content-model errors already in the publishers' own markup are tolerated, their count pinned in a golden).
Running
To test, run pytest -rs; -rs lists the tests skipped for
missing programs. The dev shell (nix develop) provides all of
them and makes the checkout importable, so plain pytest is
enough. Outside it, install the checkout in editable mode first
(pip install --editable . --group dev). nix flake check runs the
whole test matrix: the suite once per supported interpreter and
once against papis's development branch, no skips, plus ruff and
mypy. One cell runs alone with
nix build .#checks.x86_64-linux.test-python312.
Fixtures
The tests run on committed pages, whole captures and reductions,
listed in tests/fixtures/manifest.toml
with each one's URL and capture date.
We only commit CC BY whole captures, and their size adds up, so
there are one or two per platform, re-captured to follow what the
platforms serve. Each also has its bibliographic record in the
fixtures' papis library (tests/fixtures/library), which
tests/fixtures/papis-fixtures runs papis against with the user's
own configuration kept out.
Reductions are pages cut down to the parts that carry a form the captures do not, kept under fair use/dealing. A reduction is cut by hand or agentically when the form is seen, and stays as cut: evidence that the platform served the form at that date.
Rule coverage
Markup-handling code that grows organically/agentically turns
obscure: a selector sits in a module with no record of the page that
needed it, and line coverage reports that the query ran, whether or
not its selector matched anything. Instead, we turn most markup
knowledge in a platform module into a "rule" of one of three forms: a
selector, an attribute name or pattern, or an id derived for a link's
target - all forced (with ruff/mypy) to run through their instrumented
version in
papis_make_epub/sources/node.py.
Each rule needs to be represented in the fixtures:
tests/test_rules.py fails on a rule that
matched in no fixture of its platform. To see which fixtures (or pages
in a dir) carry each rule's form, run
tools/fixture_coverage.py.
Goldens and re-capture
Two events change what the code produces, failing the golden
tests: a fix or improvement to the extraction, and a re-capture
tracking what the publishers serve (procedure below). In both
cases: 1. regenerate with pytest --force-regen, saving the
extraction's structure, packaging, and text to the golden files,
2. review the diff to make sure the changes are expected, and
3. commit the goldens together with what moved them.
To re-capture, run nix run .#refresh-fixtures (-- --help for
its options). The scripted captures run first; then each manual
capture is walked through in turn, its instructions printed and the
run waiting until the file is saved, or skipped. A capture that
validates gets the day's date written into the manifest. Then
regenerate, review, and commit as described above.
Two occasions call for a reduction.
- A fix: the reduction is cut from the page that showed the problem and is its regression test.
- A re-capture: the rule test fails when the platform has stopped serving a form a rule handles. The reduction, cut from the previous capture, keeps the form in the corpus, so pages saved while the platform served it still build.
Metadata
Release files for papis-make-epub 0.1.0
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 |
|---|---|---|---|---|
| papis_make_epub-0.1.0.tar.gz | 2.7 MB | Without provenance | Details for papis_make_epub-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| papis_make_epub-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for papis_make_epub-0.1.0-py3-none-any.whl |
Total release size: 2.8 MB
Release files / papis_make_epub-0.1.0.tar.gz
| Download URL | papis_make_epub-0.1.0.tar.gz |
|---|---|
| Size | 2.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcbe0f1a17e858529ae292eb4096ee02c691a8abb817b5109bdd54d794af417d
|
|
BLAKE2b-256 checksum How to use checksums |
9e1f9ea2bf535c1b12d3f38224e2c7917f8d3dc61f82ee2d33f082f9935db138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / papis_make_epub-0.1.0-py3-none-any.whl
| Download URL | papis_make_epub-0.1.0-py3-none-any.whl |
|---|---|
| Size | 86.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
798d15184631a6fbe1e7752714fd0ac83c84b40b364b55f89dc169136a76b4ad
|
|
BLAKE2b-256 checksum How to use checksums |
935235fe025976df748d1f75a6a957e098831daee2a501091b0dd157a23e79a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for papis-make-epub 0.1.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.