Repository navigation
stage-site --local-links: read pages with MyST's own parser - #109
Conversation
- A lecture's original left by an earlier --clean, which kept the lecture, no longer refuses staging when it holds what the pool's lecture holds now (put back by hand, say), since replacing it loses nothing. One that differs still refuses. - The originals folder: staging refuses when it is a link or a file, and when a lecture's place in it holds a link, dangling ones included (a dangling link is not .exists(), and copying the original would have written through it). The confinement --clean reads refuses a folder that is itself a link, whose target it would otherwise confine to. - The paragraph reading, as CommonMark has it: an ordered item other than 1. ends a paragraph only in a list (`2024. Then` continues one), and an item indented four spaces or more only in a list, as a nested item. The docstring no longer lists these two among the misreadings. On the pool the reading is unchanged, and dp's plan is the same 31 links in 13 lectures. Each fix has a test that fails on main (9f3a710). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
- The cache save runs on always() with the HTML build's outcome, so a job that times out or is cancelled in a later step (the PDF, say) still keeps a cold build's execution; the header's step 11 says so. - The header's cache paragraph and sites/README.md no longer say the cache is saved "after a green build": it is after an HTML build that succeeded, whatever a later step did. - The copy step's grep: finding nothing (exit 1) is the check's to report, and a real error (exit 2, an unreadable folder) now fails the step with grep's own message, where `|| true` let it pass green. - sites/README.md's publishes row no longer says "the same way" twice; a comment left short by rewrapping is rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
stage-site's paragraph reading: - A nested list numbered other than 1 cannot interrupt a paragraph, in a list or not: an ordered item numbered other than 1 ends one only at the indent of the list's last item or less (a sibling, or a parent's). The docstring said "as CommonMark has it" for a rule that read `- a` then ` 2. b`, or `1. a` then ` 14. b`, as items. - A list ends at any block that is not indented and is not an item (a heading too), not only at a paragraph after a blank line. - Against markdown-it with MyST's block plugin, on 21 cases: 0 disagreements (db8cd72: 4, each a link in a literal rewritten). - Tests: the review's three cases, `1. a` then ` 2. b`, the list ending at a paragraph (it fails without the reset line) and at a heading, and a sibling a level up; an originals folder that is a plain file (it fails without that check). A link or folder where an original goes is refused as "not a plain file holding the lecture", not as "differs". site-build: - The cache save also needs the report's success: a cancel between the build and the report left `executed` empty, and the save ran. - "first green run on main" in the header and sites/README.md is now the first run whose HTML build succeeds. On the pool the reading is unchanged against main (aa281d3), and dp's plan is the same 31 links in 13 lectures. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
…ollows The maintainer chose to split the paragraph reading out of this PR (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)"). After four review rounds, the hand-written reading still disagreed with markdown-it on 9 of 62 cases, against 21 for main's. A separate PR will read paragraphs and code spans with markdown-it and MyST's plugins, so the reading is exact by construction. - tools/stage-site's prose_mask is main's (aa281d3) again, and the ten test cases written for the new reading go with it. The pool reads exactly as on main, and dp's plan is the same 31 links in 13 lectures. - Kept: the left-over original that matches the lecture, the originals folder checks, and the site-build fixes. - A test for a folder left where an original goes; it fails without `kept.is_file()`. - site-build.yml and sites/README.md: the save follows the HTML build and its execution report, as the condition reads. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
The maintainer's choice (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)"): replace the hand-written paragraph reading with the parser MyST itself uses, so what counts as a link is exact by construction rather than by more rules. - Reader builds myst-parser's markdown-it (create_md_parser) with the extensions the site's _config.yml enables, and wraps its `link` and `myst_role` inline rules to record where each link and role starts and ends. Each paragraph, heading or table cell is placed back in the source line for line, and a directive's body is read the same way, but for LITERAL_DIRECTIVES (code, math, raw). An edit is made only where the source holds, at the place found, what the parser read there; anything that cannot be placed is left as it is, linking out. - prose_mask, its fence, backtick and block-start rules go. - 66 new cases, from both oracles of the reviews of #108 and four more (table cells, a list item's next line, a blockquote, a directive in a list): the rewrite makes exactly the links markdown-it renders as links. On main's stage-site 21 of them fail. - dp's plan on the pool is the same 31 links in 13 lectures, byte for byte. - myst-parser (and linkify-it-py, for the sites' linkify) join the script's dependencies and tests.yml's; every leg's environment has them, as Jupyter Book does (myst-parser 3.0.1, markdown-it-py 3.0.0). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
|
Validation at This PR changes how
No file is in one build and not the other. Every file that differs differs only in what each build writes afresh: a notebook's cell ids and The rewrite itself is checked apart from the build, as the PR body says: 66 cases against markdown-it, and dp's plan on the pool, byte for byte. |
- A link or role is recorded only when the state it was parsed in reads the text being placed: an image's alt text is parsed again in a state of its own, whose offsets are not the paragraph's, so a link there stood for a literal's address at that place. - A table cell that cannot be placed (markdown-it unescapes a \| in it) leaves the rest of its row alone, rather than the next cell being found inside it. - Lines are split as markdown-it splits them, at \r\n, \r or \n, so a lone \r no longer shifts the rows. - The script pins myst-parser==3.0.1, the version every leg builds with, where >=3,<5 resolved to 4.0.1 and Sphinx 8 on each uv run. - Nits: LITERAL_DIRECTIVES adds eval-rst, mermaid, toctree, jupyter-execute, ipython and doctest. The default extensions are Jupyter Book 1.0.4's own (colon_fence, dollarmath, linkify, substitution, tasklist), which a site's list replaces, even an empty one. Without linkify-it-py the error is a plain one. The unused token slice goes, the edit check's docstring says what it can and cannot catch, and a long comment line is rewrapped. Tests: the alt text, the lone \r (exact output; it fails on c8cc025), the table row, the extensions, the linkify-it error. 436 passed. dp's plan is the same 31 links in 13 lectures. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
The organiser's delta review of 9b98ff1: Jupyter Book 1.0.4 sets the extensions from a site's list only when the list names any, so `myst_enable_extensions: []` keeps its defaults, as does no list. The code and its test had an empty list turn every extension off; the comment already read it right. No pool site has an empty list. Tests now pin the defaults (colon_fence, dollarmath, linkify, substitution, tasklist, and not deflist) for no `parse`, no list and an empty list, and a named list replacing them; and each of LITERAL_DIRECTIVES leaving its body unread, against a {note} that is read. The rewrite's docstring no longer says the edit check keeps an edit to one line: the two link forms span no line break. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
## Why The last open part of QuantEcon/project-monorepo#77. Its acceptance criteria: - "A pull request that touches one shared lecture rebuilds every product that lists it and no other"; - "A planted broken lecture fails every product that holds it and no other product's build". Today every pull request and push to `main` that touches a build input builds all six sites. A fix to one intro lecture also rebuilds intermediate, programming and jax on the GPU machines. For pushes to `main` the owner chose the same narrowing on 2026-11-27, in the project-monorepo session: "Affected only (Recommended)". The schedule and a manual run still build every site. ## What it adds - **`tools/affected-sites`** reads the changed paths and prints the sites, of those named, that they reach: - a lecture, or its own `_static/<slug>/` files: the sites whose `_toc.yml` lists it, at any depth of parts, chapters and sections; - a `_static/_shared/` asset: the sites of the lectures the ledger records as using it, or every site when it records none; - a `_static/<dir>/` that is no pool lecture's folder: every site; - a site's own file: that site (`sites/README.md` reaches none); - `tools/sync` and `sync/state.yml`: the sites in the `series` environment, here or at the base, since only those run `tools/sync` (today dp). `sync.yml`'s near-daily pin refresh starts no run, but the next push takes it in, and it builds dp alone; - any other build input: every site. That covers the bibliography, any other pool file, a build tool, `_base/`, `sync/manifest.yml` (which `tools/stage-site` reads for every site) and the workflow. These are the workflow's path filter outside the pool and the sites, and a test keeps the two lists in step; - anything else (documentation, the tests, another workflow, the other sync records): none. With `--base`, the contents lists and the ledger are read at the base too. So a lecture a change drops still builds the sites that listed it, and a shared asset its old users' sites. Paths come NUL-separated with `-z`. The tool refuses a `--base` that is no commit, and a contents list or ledger it can't parse, with exit 2. Links between sites don't widen the set: intersphinx resolves them against the other site's published inventory, not this build. - **`site-build.yml`**'s first job chooses the sites: - **A pull request** is compared with its base. - **A push** is compared with the head of the last build on `main` that succeeded, not the commit before it. That build may be a push, scheduled or manual one, but never a pull request's. A run cancelled while it waits (the concurrency group keeps one waiting), cancelled by hand, or failed then leaves nothing unbuilt: the next push takes its change in. A step of its own reads that run through the API, with `actions: read`. It runs only on a push, and is the only step that holds the token. - **While a site stays red on `main`,** no build succeeds, so each push builds all that has changed since the last green build. The header says to mend a red site first. It also says to re-run an older push build's failed jobs, not all its jobs. - **The schedule and a manual run** take every site, and so does a base that can't be found or fetched. - The diff is `git diff --no-renames --name-only -z`. A renamed or moved file counts by its old path as well as its new one, and a name git would quote keeps its bytes. Only the base commit is fetched: a diff of two trees needs no history. - **A change to the rule itself** (the tool or this workflow) builds every site without asking the tool, so a broken tool can't skip its own build. - The job writes "Sites built: … " and the reason to the run summary. When a change reaches no site, the build job is skipped, since GitHub refuses an empty matrix. - **The header:** who builds what, and how a push is compared. "What it does not do" now puts mystmd and the shared cache in the second phase, after the cutovers, which takes in the note deferred from #110. - **Docs:** README's build paragraph and tools table, and `sites/README.md`'s "Building a site in CI". ## Checked - **Tests:** 501 passed and 1 skipped. They cover: - every rule (24 cases), including a section nested in a part and the series inputs; - a site moved out of the series environment, read at the base, and a site with no `site.yml`; - over a real git history: a dropped lecture, the ledger read at the base, a renamed lecture, an asset moved between two lectures' folders, and a name git would quote; - a key with no site, a base that is no commit, and a contents list that can't be parsed; - the workflow, read for its path filter (both events), its diff flags, the rule check, the push base's query step, and that only that step holds the token. Six of the new tests fail on the first version of the tool, and dropping the ledger's base reading fails one. actionlint and pool-check are clean. - **On the real pool,** with the workflow's own diff command: - `git mv lectures/os_stochastic.md lectures/os_stochastic_v2.md` builds dp and intermediate; - moving an `about_py` figure into `os_stochastic`'s folder builds dp, programming and intermediate; - a new `_static/lecture_specific/…` builds all six; - `about_py/café.png` builds programming; - the pin refresh `fc2ea1f` builds dp alone. - **On tonight's merges** (each squash commit against its parent): | Merge | Sites it would build | |---|---| | the refresh #107 (two intro lectures) | intro alone, instead of all six | | #101 (pool-check, its tests, `sites/README.md`) | none; it built all six | | #110 (the README) | none | | #106 (`site-build.yml`) | all six | | #109 (`tools/stage-site`) | all six | - **Real runs, each from a throwaway draft against this branch, now closed:** - #112 planted a failing cell in a lecture that dp and intermediate list. Only those two legs ran, and both failed in the strict build on the planted error. - #113 changed only `sites/README.md`. The matrix job reported no site, and the build job was skipped. The evidence comments below have the details. - **This PR's own build** changes the workflow, so it builds all six: the "rule itself" path. - **The push path** can't run before the merge. Its query, run now against this repository, returns 31f29fc (#101), the last build on `main` that succeeded. The first push after the merge carries this workflow, so it builds all six. The "Sites built" summaries of the first two push builds on `main` are to be read after the merge. The first should say it touches the rule, against 31f29fc. The second should be compared with the merge commit, if the first went green. The validation rule: this changes which sites build, not how. The legs that run are unchanged steps, so a full output comparison isn't needed. The planted test is the evidence. Copilot: not requested (Matt, 2026-11-22). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
Why
tools/stage-site --local-linksrewrites a consumer site's links to lectures it carries (#102). It must leave alone a link that isn't one, such as an address inside an inline literal or a code cell. Until now it found those with hand-written rules for paragraphs and code spans. Four review rounds of #108 each found new list-indentation cases where those rules and CommonMark disagree. On the 62 cases the reviews checked against markdown-it, main's reading disagrees on 21. The maintainer chose to split that work out of #108 and read pages with markdown-it itself (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)").What it changes
Readerbuilds the parser MyST itself uses, myst-parser's markdown-it (create_md_parser), with the extensions the site's_config.ymlenables (parse: myst_enable_extensions). It wraps the parser'slinkandmyst_roleinline rules so that each records where its link or role starts and ends. A link counts only where the parser makes one, so none comes from a code cell, a literal block, an inline literal, a%comment, raw HTML or maths.>it carried. Cells of one row are found left to right. A directive's body is read the same way, except forLITERAL_DIRECTIVES(code, math, raw). An edit is made only where the source holds, at the place found, exactly what the parser read there. Anything that can't be placed is left as it is, still linking out, as every link did before--local-links.prose_maskand its fence, backtick and block-start rules.myst-parserandlinkify-it-py(for the sites'linkify) join the script's uv header andtests.yml. Every leg's environment has them, since Jupyter Book does (myst-parser 3.0.1, markdown-it-py 3.0.0). Without myst-parser,--local-linksfails with a plain error. The site-build comment andsites/README.mdsay so.Checked
mdit-oracle.pyand the organiser's 41), the rewrite makes exactly the links markdown-it renders as links. Those 62, and four more (table cells, a list item's next line, a blockquote, a directive in a list), are now a test: 66 cases, 21 of which fail on main'stools/stage-site.4b0ab02): dp's--local-linksplan is the same 31 links in 13 lectures, byte for byte.This PR's site build runs all six sites, since it touches
tools/stage-site. No site setslocal_links, so no page changes.Copilot: not requested (Matt, 2026-11-22).
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG