math-parser-formatter
Skill246 starsChanged 22 days agoMITView on GitHub
Implement or debug Panache's TeX math parser and formatter
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-lint-ruleSkill
- add-syntax-constructSkill
- commonmark-conformanceSkill
- external-toolsSkill
- html-conformanceSkill
- linter-investigationSkill
- pandoc-ir-migrateSkill
- perf-investigationSkill
- smoke-test-triageSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 11 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Treat math formatting as a stable, issue-driven subsystem.
- Distinctive: line 40
Follow the parser, math, formatter, linter, and language-server invariants in the repository's root AGENTS.md for every layer the change …
- Very specific: line 45
Keep parsing unconditional, single-pass, lossless, and error-tolerant.
- Very specific: line 49
Keep Markdown delimiters, Bookdown equation labels, Pandoc attributes, and container prefixes at the host layer where possible.
- Very specific: line 52
Keep MATH_SPACE and MATH_NEWLINE distinct from host trivia, and read math source through syntax::math::math_content_text() when container …
- Distinctive: line 55
Keep the lexical CST neutral.
- Distinctive: line 58
Keep Badness test-only. Production code must not retain or project a Badness tree, delegate parsing or formatting to Badness, or depend on …
- Distinctive: line 63
Do not broaden the formatter's rewrite boundary merely to increase oracle parity.
- Very specific: line 65
Do not rewrite macros, canonicalize \frac and \dfrac, or format constructs whose meaning would require macro expansion.
- Distinctive: line 67
If a pinned Badness defect explains a divergence, record the defect and tell the user.
- Distinctive: line 77
Read the relevant source of truth above.
- Distinctive: line 80
Add the smallest focused failing test first.
- Distinctive: line 84
Keep named intentional differences and preservation cases explicit.
- Distinctive: line 87
Run the focused suite for each changed layer:
- Distinctive: line 97
If the formatter corpus, route census, or parity classification changes, regenerate and review the tracked report with:
- Very specific: line 105
Before landing a code change, run the workspace validation required by root AGENTS.md.
- Very specific: line 110
Update STYLE.md, user documentation, configuration schema, oracle reports, or this skill only when the behavior or durable maintenance …
- Distinctive: line 112
Do not update the completed roadmap or historical baselines for an unrelated fix.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Maintain the math parser and formatter
Treat math formatting as a stable, issue-driven subsystem. The migration
roadmap in TODO.md is complete; do not use it as a work queue.
Project source paths below are relative to the repository root. Skill resources
are relative to this SKILL.md.
Scope and sources of truth
- The TeX content parser is
crates/panache-parser/src/parser/math.rs; host embedding lives incrates/panache-parser/src/parser/inlines/math.rs, and typed accessors live incrates/panache-parser/src/syntax/{math,inlines}.rs. - The formatter lives in
crates/panache-formatter/src/formatter/math/andcrates/panache-formatter/src/formatter/math.rs. Its user-facing policy is the stable[format] mathmode, which defaults toreflow. The[experimental] format-mathboolean is a deprecated compatibility alias. - For changes to user-visible formatting behavior, read
crates/panache-formatter/src/formatter/math/STYLE.md; it is the canonical style and preservation contract. - For cross-layer parser, semantic, or formatter work, read REFERENCE.md before changing behavior. It records the non-obvious implementation constraints, intentional oracle differences, and stabilization baseline.
- Pandoc is not an oracle for math formatting because it preserves math
content. Use the exact, pinned
badness-parserandbadness-formatterdevelopment dependencies as structural and output oracles. Retain independent MathML and TeX/PDF checks when meaning preservation is at risk.
Follow the parser, math, formatter, linter, and language-server invariants in
the repository's root AGENTS.md for every layer the change touches.
Invariants
- Keep parsing unconditional, single-pass, lossless, and error-tolerant. The
formatter option controls rewriting; it is not a Pandoc
Extensionsflag. - Derive
MathDiagnosticvalues throughmath_diagnostics()as a side channel. Do not encode diagnostics as CST structure. - Keep Markdown delimiters, Bookdown equation labels, Pandoc attributes, and
container prefixes at the host layer where possible. Equation labels remain
host tokens between ordered
MATH_CONTENTsegments. - Keep
MATH_SPACEandMATH_NEWLINEdistinct from host trivia, and read math source throughsyntax::math::math_content_text()when container prefixes may be interleaved. - Keep the lexical CST neutral. Derive operator class, delimiter role, contextual unary coercion, and break priority through the shared semantic atom model rather than formatter-local token interpretation.
- Keep Badness test-only. Production code must not retain or project a Badness tree, delegate parsing or formatting to Badness, or depend on Badness at runtime. Test projectors may only perform mechanical kind and wrapper normalization; they must not parse, infer attachment, or repair a tree.
- Preserve source bytes when syntax is malformed or semantics cannot be proven. Do not broaden the formatter's rewrite boundary merely to increase oracle parity.
- Do not rewrite macros, canonicalize
\fracand\dfrac, or format constructs whose meaning would require macro expansion. - If a pinned Badness defect explains a divergence, record the defect and tell the user. Do not copy the defect into production code or silently reclassify the case.
Workflow
- Reproduce the smallest failing behavior and identify the owning layer: host parsing, TeX CST, semantic atoms, formatter lowering/layout, configuration, diagnostics, or position mapping. Inspect the CST before adding a formatter workaround.
- Read the relevant source of truth above. Verify current implementation when documentation, reports, and behavior disagree; correct only stale material within the requested scope.
- Add the smallest focused failing test first. Use parser goldens for CST shape, formatter goldens for user-visible output, and unit or differential tests for semantic behavior.
- Compare against the pinned Badness oracle when the shared behavior applies. Keep named intentional differences and preservation cases explicit. Use MathML or representative TeX/PDF checks when byte parity does not establish semantic equivalence.
Run the focused suite for each changed layer:
- Parser CST:
cargo test -p panache-parser --test math_badness_parity - Semantic model:
cargo test -p panache-parser --test math_semantic_parity - Formatter output:
cargo test -p panache-formatter --test math_badness_oracle - Formatter behavior and host integration: the smallest matching tests under
crates/panache-formatter/tests/and the root golden suite.
- Parser CST:
If the formatter corpus, route census, or parity classification changes, regenerate and review the tracked report with:
cargo test -p panache-formatter --test math_badness_oracle \ math_badness_full_report -- --ignored --nocapture- Before landing a code change, run the workspace validation required by root
AGENTS.md. Review every parser snapshot diff for losslessness, verify formatter idempotency, and keep math content byte-identical inverbatimmode. Do not rerun a focused suite after an equivalent workspace gate on the same tree state. - Update
STYLE.md, user documentation, configuration schema, oracle reports, or this skill only when the behavior or durable maintenance contract changes. Do not update the completed roadmap or historical baselines for an unrelated fix. Commit only when the user has requested it, following repository guidance.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

