Repository navigation
Description
Summary
A standalone MyST Markdown linting tool that validates syntax and provides deterministic error detection for MyST documents. This tool would support the translation sync pipeline and can be used independently for quality assurance across all QuantEcon lecture repositories.
Background
During evaluation of the action-translation-sync tool (v0.6.0), human reviewer @HumphreyYang identified markdown syntax errors in translator output that were not caught:
- Missing space after
####in headings (e.g.,####Titleinstead of#### Title) - Incorrect code block delimiters
- Math block delimiter mismatches
While we have added LLM-based syntax checking to prompts as a first line of defense, a deterministic linting tool would provide:
- 100% reliable detection (vs ~90% from LLM)
- No API costs
- Fast validation
- CI/pre-commit integration
Proposed Solution
Build myst-lint as a standalone tool that wraps markdownlint (5.3M monthly downloads, actively maintained) with MyST-specific extensions.
Architecture
┌─────────────────────────────────────────────────────────────┐
│ myst-lint │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ markdownlint │ + │ MyST Custom Rules (optional) │ │
│ │ (core rules) │ │ - directive validation │ │
│ │ - MD018 (ATX) │ │ - role validation │ │
│ │ - MD031 (code) │ │ - math delimiter matching │ │
│ │ - MD040 (lang) │ │ - code-cell validation │ │
│ └─────────────────┘ └─────────────────────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────┤
│ CLI: myst-lint <file.md> [options] │
│ API: import { lintMyST } from "myst-lint" │
└─────────────────────────────────────────────────────────────┘
Integration Points
Source Repo ──► [myst-lint] ──► Valid input guaranteed
│
▼
Translator ──► [myst-lint] ──► Block sync if errors
│
▼
Target Repo PR ◄── Sync ◄── Valid translated content
│
└──► [Evaluator] ──► Failsafe LLM check (advisory)
- Source validation: Lint English source before translation (assume valid input)
- Output validation: Lint translator output before sync (catch translator-introduced errors)
- CI integration: Pre-commit hooks for lecture repositories
- Evaluator failsafe: LLM-based check as backup (already implemented)
Core markdownlint Rules (Built-in)
These rules work out of the box with MyST:
| Rule | Description | Catches |
|---|---|---|
| MD018 | No space after hash on ATX heading | ####Title → error |
| MD031 | Fenced code blocks surrounded by blank lines | Structure issues |
| MD040 | Fenced code blocks should have language | Missing language spec |
| MD047 | Files should end with single newline | Formatting |
MyST Custom Rules (Phase 2)
Extend markdownlint with MyST-specific validation:
| Rule | Description |
|---|---|
| myst-directive-known | Validate {directive-name} is recognized |
| myst-directive-options | Check :option: value syntax |
| myst-role-syntax | Validate {role}\target`` format |
| myst-math-delimiters | Check $$ pairs are balanced |
| myst-code-cell-tags | Validate code-cell tag syntax |
Implementation Plan
Phase 1: Core Tool (MVP)
- Wrap markdownlint with MyST-friendly config
- Disable rules that conflict with MyST syntax
- CLI and programmatic API
- Integration with
action-translation-sync
Phase 2: MyST Custom Rules
- Implement directive/role validation
- Math delimiter checking
- Code-cell validation
Phase 3: CI Integration
- Pre-commit hooks
- GitHub Actions workflow
- VS Code extension recommendations
Technical Details
Base Package: markdownlint v0.39.0
- 5.3M monthly downloads
- Actively maintained (last release Oct 2025)
- Supports custom rules via micromark parser
- Works with MyST out of the box (no false positives on directives)
Testing Performed:
$ echo "####NoSpaceHeading" | npx markdownlint-cli --stdin
stdin:1:1 MD018/no-missing-space-atx No space after hash on atx style headingMyST directives ({note}, {code-cell}, etc.) are correctly ignored as valid code blocks.
Priority
MEDIUM - The LLM-based syntax checking provides good coverage now. This tool would provide deterministic guarantees and enable broader use across the organization.
Related
- action-translation-sync#4 - Evaluation Tool Improvements
- markdownlint - Base linting library
- markdownlint CustomRules.md - Custom rule documentation
Activity
feat: add markdown syntax validation to translator and evaluator prompts
mmcky commentedon Jun 4, 2026
Related: #320 (
PROJECT: action-code-style— deterministicblackformatting of Python inside MyST{code-cell}and fenced markdown blocks).It shares this project's design philosophy exactly (deterministic, no API cost, fast, CI/pre-commit) but a different concern:
black(PEP8).Open question to settle jointly: one tool or two?
black-formatting could be a separate sibling action, or a code-format pass/rule-set withinmyst-lint(one deterministic "MyST quality" tool with both a structure-lint and a code-format pass). Worth deciding before either is built.mmcky commentedon Jun 11, 2026
Scope note from the style-guide consolidation program: we've decided
myst-lintand the program's planned style checker (qestyle-linter) are siblings, not layers — two tools for two concerns.myst-lint(this issue): is the document well-formed MyST? Malformed directives, unmatched math delimiters, missing lang tags — universal, nothing QuantEcon-specific.qestyle-linter(the program): is it written in QuantEcon house style? (\topnot^T,alignednotalign, etc.) — a style violation is still valid MyST.They coexist in CI and share at most a MyST parsing library (an implementation choice, not a product dependency). So MyST validity rules stay in scope here; QuantEcon style rules will live in the program's linter. Cross-reference: QuantEcon/project-style-guide decision D9.
1sgtpepper commentedon Jun 15, 2026
Hi QuantEcon team, I think SciEqLint may already cover a large part of the deterministic
myst-lintlayer being discussed here.The fit is mainly around the generated-translation workflow you’ve already described: translation output can look fine at review time but still contain structural MyST issues that only show up later in CI/Jupyter Book. SciEqLint is built for that gap: deterministic scientific Markdown/MyST checks, no API cost, GitHub annotations/SARIF, and a generated-MyST preset that can run immediately after translation output is produced.
For this issue, #268, SciEqLint already covers many of the proposed
myst-lintchecks: malformed headings like####Title, unclosed fenced blocks, unclosed math containers, missing fence info strings, malformed MyST directives/options/roles, code-cell metadata issues, heading hierarchy problems, and missing/ambiguous{ref}targets. This seems aligned with the scope note here: validate whether the document is well-formed MyST, while keeping QuantEcon house style separate.For QuantEcon/action-translation#4, it looks like the evaluator improvements were mostly handled, with deterministic
myst-lintleft as a future item. SciEqLint could provide that deterministic layer after translation output is generated, while the LLM evaluator stays focused on prose and translation quality.For QuantEcon/action-translation#65, SciEqLint handles MyST heading anchors like
(label)=and reports missing or ambiguous generic{ref}targets. That should catch dropped-anchor cases like(jax_at_workaround)=being removed while a later{ref}still points to it, before Jupyter Book fails.A minimal trial would be:
I don’t want to derail the existing direction, especially since the discussion already separates
myst-lint,qestyle-linter, andaction-code-stylewell. But if this is useful as a starting point or reusable validation layer, I’d be happy to adapt SciEqLint around QuantEcon fixtures, edge cases, or rule preferences.