Repository navigation
stage-site and site-build: the follow-ups from the reviews of QuantEcon/lectures#102 and #106 - #108
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
|
Validation at This PR changes how the site build saves its cache and how the PDF copy step reads grep's exit status. It changes no command that makes a page, a notebook or a PDF, and
No file is in one build and not the other. Every difference is something each build writes afresh:
The two behaviours that changed are tested apart from the build, as the PR body says: the tests for |
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
## Why `tools/stage-site --local-links` rewrites 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 - **`Reader`** builds the parser MyST itself uses, myst-parser's markdown-it (`create_md_parser`), with the extensions the site's `_config.yml` enables (`parse: myst_enable_extensions`). It wraps the parser's `link` and `myst_role` inline 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. - **Placing back.** Each paragraph, heading or table cell the parser reads is found again in its source lines, one line for one, after any list indent or `>` it carried. Cells of one row are found left to right. A directive's body is read the same way, except for `LITERAL_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`. - **Gone:** `prose_mask` and its fence, backtick and block-start rules. - **Dependencies:** `myst-parser` and `linkify-it-py` (for the sites' `linkify`) join the script's uv header and `tests.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-links` fails with a plain error. The site-build comment and `sites/README.md` say so. ## Checked - **Against markdown-it:** on all 62 cases from the two oracles of #108's reviews (`mdit-oracle.py` and 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's `tools/stage-site`. - **On the pool** (at `4b0ab02`): dp's `--local-links` plan is the same 31 links in 13 lectures, byte for byte. - **Tests:** 428 passed and 1 skipped, including the existing prose cases and a test for the missing-parser error. actionlint and pool-check are clean. This PR's site build runs all six sites, since it touches `tools/stage-site`. No site sets `local_links`, so no page changes. Copilot: not requested (Matt, 2026-11-22). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
Why
The reviews of #102 (
tools/stage-site --local-links) and #106 (the PDF) left points to take after their merges. This PR takes them. None changes what any site builds or publishes today.tools/stage-site (from the reviews of #102)
--cleanthat kept an edited lecture leaves its original under_build/stage-site-originals/, and staging refused while it was there. It now refuses only when the original differs from the pool's lecture as it is now. Once the lecture has been put back by hand, replacing the original loses nothing._build/stage-site-originalsis a link or a file. It also refuses when a lecture's place in that folder holds a link, dangling ones included. A dangling link is not.exists(), so copying the original would have written through it. The confinement--cleanuses refuses a folder that is itself a link, whose target it would otherwise confine to.tools/stage-sitereads paragraphs, so that inline literals are found as CommonMark finds them. After four review rounds, that hand-written reading still disagreed with markdown-it on 9 of 62 cases, against 21 for main's. The maintainer chose to split it out (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)"). Soprose_maskis main's again, and a separate PR will read paragraphs and code spans with markdown-it and MyST's plugins, exact by construction.site-build.yml (from the review of #106)
always()with the outcome of the HTML build and of its execution report. A job that times out or is cancelled in a later step, the PDF build say, still keeps a cold build's execution. The header's cache paragraph andsites/README.mdno longer say "after a green build".|| truehad let that pass green.sites/README.md'spublishesrow no longer says "the same way" twice, and a comment left short by rewrapping is rewrapped.Checked
aa281d3): the reading is main's, so every pool lecture reads as on main (0 lines differ), and dp's--local-linksplan is the same 31 links in 13 lectures, byte for byte.5498ef2). Each fix has a test that fails without it: the left-over original that matches (put back and staged again), a dangling link where an original goes, a folder there, and an originals folder that is a link or a file, at staging and at--clean.bash --noprofile --norc -eo pipefailon local cases:|| trueit passed).This PR's site build runs all six sites, since it touches
tools/stage-site. Every leg restores main's cache.Copilot: not requested (Matt, 2026-11-22).
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG