Also called: Bread crust; The <hard> shell
", self.html("crust.html")) self.assertNotIn("Also called", self.html("sourdough.html")) def test_a_footnote_links_to_its_source_entry_with_quote_locator_and_raw_link(self) -> None: view.render(self.bundle, self.sources, self.out) page = self.html("sourdough.html") self.assertIn('href="#src-b-3"', page) entry = page[page.index('id="src-b-3"'):] entry = entry[:entry.index("")] self.assertIn("The dough rests for twelve hours", entry) self.assertIn("line 3", entry) self.assertIn("/kilde/bread.md", entry) self.assertIn('href="raw/kilde/bread.md.html#L3"', entry) def test_footnotes_are_numbered_by_first_use(self) -> None: view.render(self.bundle, self.sources, self.out) page = self.html("sourdough.html") refs = re.findall(r']*>(\d+)', page) self.assertEqual([("b-2", "1"), ("b-3", "2"), ("b-3", "2"), ("o-2", "3"), ("b-2", "1"), ("b-2", "1"), ("b-2", "1")], refs) def test_the_raw_view_has_one_anchor_per_line_and_marks_the_cited_lines(self) -> None: view.render(self.bundle, self.sources, self.out) raw = self.html("raw/kilde/bread.md.html") for n in (1, 2, 3, 4): self.assertIn(f'id="L{n}"', raw) self.assertRegex(raw, r'starter.cfg", page)
self.assertIn("[^b-9]", page)
self.assertIn('Crust', page)
self.assertIn('Flour mills', page)
self.assertIn("', '", rye[rye.index('class="pop"'):]) def test_the_popup_is_shown_on_hover_and_on_focus(self) -> None: self.assertRegex(view.STYLE, r"\.cite:hover \.pop") self.assertRegex(view.STYLE, r"\.cite:focus-within \.pop") def test_see_also_lists_linked_pages_both_ways_before_the_sources(self) -> None: view.render(self.bundle, self.sources, self.out) sourdough, crust = self.html("sourdough.html"), self.html("crust.html") for page, other in ((sourdough, "crust.html"), (crust, "sourdough.html")): block = page[page.index("'), encoding="utf-8") self.assertEqual(FOOTNOTES - 1, view.check(self.bundle, self.out).resolved) def test_a_missing_page_fails_all_its_footnotes(self) -> None: view.render(self.bundle, self.sources, self.out) (self.out / "sourdough.html").unlink() result = view.check(self.bundle, self.out) self.assertEqual((1, FOOTNOTES), (result.resolved, result.total)) self.assertEqual((0, 7), result.per_page["sourdough.md"]) MIXER_NOTES = """## 1.4.2 - Added a rye flour setting to the mixer - The mixer requires firmware 3.2.1 or later ## 1.3.0 - Removed the knead timer ## 1.2.0 - Added the knead timer """ MIXER = """--- type: Concept title: Mixer description: The dough mixer. sources: - id: h142 resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 1 } x-quote: '1.4.2' - id: rye resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 2 } x-quote: 'Added a rye flour setting to the mixer' - id: fw resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 3 } x-quote: 'The mixer requires firmware 3.2.1 or later' - id: h130 resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 4 } x-quote: '1.3.0' - id: removed resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 5 } x-quote: 'Removed the knead timer' - id: h120 resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 6 } x-quote: '1.2.0' - id: knead resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 7 } x-quote: 'Added the knead timer' x-outdated: [{ old: knead, new: removed }] generated: { by: claude-code/claude-opus-5-5, at: 2026-09-28T09:00:00Z } --- # Mixer - Version 1.4.2 added a rye flour setting to the mixer.[^h142][^rye] - The mixer has a rye flour setting.[^h142][^rye] - Since v1.4.2 the mixer has a rye flour setting.[^h142][^rye] - The mixer requires firmware 3.2.1 or later.[^h142][^fw] - Version 1.2.0 added the knead timer.[^h120][^knead] Version 1.3.0 removed the knead timer.[^h130][^removed] - The setting `rye-1.4.2` names the flour.[^rye] [^h142]: Mixer notes, line 1 [^rye]: Mixer notes, line 2 [^fw]: Mixer notes, line 3 [^h130]: Mixer notes, line 4 [^removed]: Mixer notes, line 5 [^h120]: Mixer notes, line 6 [^knead]: Mixer notes, line 7 """ RELEASE_PAGE = """--- type: Concept title: Release 1.4.2 description: What release 1.4.2 of the mixer changed. sources: - id: h142 resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 1 } x-quote: '1.4.2' - id: rye resource: /kilde/mixer.md title: Mixer notes x-locator: { line: 2 } x-quote: 'Added a rye flour setting to the mixer' generated: { by: claude-code/claude-opus-5-5, at: 2026-09-28T09:00:00Z } --- # Release 1.4.2 Version 1.4.2 added a rye flour setting to the mixer.[^h142][^rye] [^h142]: Mixer notes, line 1 [^rye]: Mixer notes, line 2 """ # Claim sentences: sourdough 5, crust 1, mixer 7, release 1. Version numbers in running text that are not the claim: # mixer "Version 1.4.2 added" and "Since v1.4.2". Licensed: firmware 3.2.1 (in the content quote), the Outdated pair # (2 sentences) and the release page (its title holds the version). The code span `rye-1.4.2` is not running text. CLAIMS_ALL = 14 class VersionFixture(Fixture): def setUp(self) -> None: super().setUp() (self.sources / "kilde" / "mixer.md").write_text(MIXER_NOTES, encoding="utf-8") (self.bundle / "mixer.md").write_text(MIXER, encoding="utf-8") (self.bundle / "release-1-4-2.md").write_text(RELEASE_PAGE, encoding="utf-8") class VersionCountTest(VersionFixture): def test_counts_version_numbers_in_running_text_that_are_not_the_claim(self) -> None: result = view.versions(self.bundle, self.sources) self.assertEqual(CLAIMS_ALL, result.total) self.assertEqual(["Since v1.4.2 the mixer has a rye flour setting.", "Version 1.4.2 added a rye flour setting to the mixer."], sorted(f.sentence for f in result.flagged)) self.assertEqual({"mixer.md"}, {f.page for f in result.flagged}) self.assertEqual({"outdated": 2, "content-quote": 1, "page-title": 1}, result.licensed) def test_a_bundle_without_version_numbers_counts_zero(self) -> None: for name in ("mixer.md", "release-1-4-2.md"): (self.bundle / name).unlink() result = view.versions(self.bundle, self.sources) self.assertEqual((0, 6), (len(result.flagged), result.total)) def test_the_version_heading_footnote_is_a_quote_of_only_a_version(self) -> None: self.assertTrue(view.is_version_heading({"x-quote": "1.4.2"})) self.assertTrue(view.is_version_heading({"x-quote": "v2.10.0"})) self.assertFalse(view.is_version_heading({"x-quote": "Added a rye flour setting"})) self.assertFalse(view.is_version_heading({"x-quote": "4.7"})) self.assertFalse(view.is_version_heading({})) class VersionLabelTest(VersionFixture): def test_a_version_heading_footnote_renders_as_a_grey_version_label(self) -> None: view.render(self.bundle, self.sources, self.out) page = self.html("mixer.html") self.assertRegex(page, r']*>1\.4\.2') self.assertRegex(page, r']*>\d+') self.assertNotRegex(page, r' None: self.assertRegex(view.STYLE, r"sup \{[^}]*font-size: 0\.7") def test_the_check_still_resolves_every_footnote_with_labels(self) -> None: view.render(self.bundle, self.sources, self.out) result = view.check(self.bundle, self.out) self.assertEqual(result.total, result.resolved) self.assertEqual((13, 13), result.per_page["mixer.md"]) class ReadableTest(VersionFixture): """Plan row L4, the PM's addendum of 28.09: references do not dominate the text, related pages are visible.""" def item(self, page: str, start: str) -> str: at = page.index(start) return page[at:page.index("", at)] def test_one_discreet_marker_per_sentence_opens_its_quotes_and_raw_lines(self) -> None: view.render(self.bundle, self.sources, self.out) page = self.html("sourdough.html") rest = self.item(page, "Rest the dough") self.assertEqual(1, rest.count('class="mark"')) pop = rest[rest.index('class="pop"'):] self.assertIn('href="#src-b-3"', pop) self.assertIn('href="#src-o-2"', pop) self.assertIn("The dough rests for twelve hours", pop) self.assertIn('href="raw/kilde/oven.md.html#L2"', pop) self.assertIn('tabindex="0"', rest) self.assertEqual(1, self.item(page, "Feed the starter").count('class="mark"')) self.assertNotRegex(page, r"\s* None: view.render(self.bundle, self.sources, self.out) rye = self.item(self.html("mixer.html"), "The mixer has a rye flour setting.") self.assertLess(rye.index(">1.4.2"), rye.index('class="mark"')) self.assertNotIn(">1.4.2
Sourdough needs a starter")) def test_the_check_still_resolves_every_footnote(self) -> None: view.render(self.bundle, self.sources, self.out) result = view.check(self.bundle, self.out) self.assertEqual((5, 5), result.per_page["starter.md"]) self.assertEqual(result.total, result.resolved) class SourceListTest(VersionFixture): """Plan row L4, the PM's addendum 3: the source list is for people, so it is closed and grouped by section.""" def test_the_source_list_is_closed_by_default(self) -> None: view.render(self.bundle, self.sources, self.out) page = self.html("mixer.html") self.assertRegex(page, r'Sources \(7\)') self.assertNotRegex(page, r'
None: view.render(self.bundle, self.sources, self.out) page = self.html("mixer.html") listing = page[page.index(SOURCES_LIST):] groups = re.findall(r"(.*?)
", listing) self.assertEqual(["Mixer notes › 1.4.2 (lines 1–3)", "Mixer notes › 1.3.0 (lines 4–5)", "Mixer notes › 1.2.0 (lines 6–7)"], groups) self.assertIn("Bread notes › Bread notes (lines 2–3)", self.html("sourdough.html")) def test_read_more_links_each_section_the_page_draws_on(self) -> None: view.render(self.bundle, self.sources, self.out) page = self.html("mixer.html") block = page[page.index("Read more in
"):page.index(SOURCES_LIST)] self.assertEqual([("raw/kilde/mixer.md.html#L1", "Mixer notes › 1.4.2"), ("raw/kilde/mixer.md.html#L4", "Mixer notes › 1.3.0"), ("raw/kilde/mixer.md.html#L6", "Mixer notes › 1.2.0")], re.findall(r'([^<]+)', block)) def test_the_check_still_resolves_every_footnote(self) -> None: view.render(self.bundle, self.sources, self.out) result = view.check(self.bundle, self.out) self.assertEqual((result.total, result.total), (result.resolved, result.total)) BAKE_NOTES = """# Bake notes ## Shaping Fold the dough twice. ```markdown # Not a section ``` Shape a tight ball. ~~~~ ``` ## Also not a section ``` ~~~~ - A list item with code: ``` # Still not a section ``` Score the top before baking. """ BAKE = """--- type: Concept title: Shaping description: How a loaf is shaped. sources: - id: b-ball resource: /kilde/bake.md title: Bake notes x-locator: { line: 7 } x-quote: 'Shape a tight ball.' - id: b-score resource: /kilde/bake.md title: Bake notes x-locator: { line: 17 } x-quote: 'Score the top before baking.' generated: { by: claude-code/claude-opus-5-5, at: 2026-09-28T09:00:00Z } --- # Shaping Shape a tight ball.[^b-ball] Score the top before baking.[^b-score] [^b-ball]: Bake notes, line 7 [^b-score]: Bake notes, line 17 """ class FencedHeadingTest(Fixture): """Order 14 (wave 3): the operator found section names taken from headings inside example code.""" def test_a_heading_inside_fenced_code_is_not_the_section(self) -> None: lines = BAKE_NOTES.splitlines() for line in (5, 7, 10, 15, 17): self.assertEqual((2, "Shaping"), view.nearest_heading(lines, line), f"line {line}") def test_read_more_and_the_source_list_name_the_section_outside_code(self) -> None: (self.sources / "kilde" / "bake.md").write_text(BAKE_NOTES, encoding="utf-8") (self.bundle / "shaping.md").write_text(BAKE, encoding="utf-8") view.render(self.bundle, self.sources, self.out) page = self.html("shaping.html") block = page[page.index("Read more in
"):page.index(SOURCES_LIST)] self.assertEqual([("raw/kilde/bake.md.html#L2", "Bake notes › Shaping")], re.findall(r'([^<]+)', block)) self.assertEqual(["Bake notes › Shaping (lines 7–17)"], re.findall(r"(.*?)
", page[page.index(SOURCES_LIST):])) self.assertNotIn("not a section", page) SAME_LINE = """--- type: Concept title: Feeding description: How a starter is fed. sources: - id: f-starter resource: /kilde/bread.md title: Bread notes x-locator: { line: 2 } x-quote: 'Sourdough needs a starter' - id: f-daily resource: /kilde/bread.md title: Bread notes x-locator: { line: 2 } x-quote: 'fed daily' generated: { by: claude-code/claude-opus-5-5, at: 2026-09-28T09:00:00Z } --- # Feeding Sourdough needs a starter.[^f-starter] The starter is fed daily.[^f-daily] - A starter, fed daily.[^f-starter][^f-daily] [^f-starter]: Bread notes, line 2 [^f-daily]: Bread notes, line 2 """ class SameLinePopupTest(Fixture): """Order 14 (wave 3): two claims cite the same line with different quotes; each popup must show the quote that supports its own claim, not the other entry's.""" def setUp(self) -> None: super().setUp() (self.bundle / "feeding.md").write_text(SAME_LINE, encoding="utf-8") view.render(self.bundle, self.sources, self.out) self.page = self.html("feeding.html") def pop_after(self, start: str, end: str) -> str: part = self.page[self.page.index(start):] return part[part.index('class="pop"'):part.index(end)] def test_each_popup_shows_its_own_quote(self) -> None: self.assertEqual(["Sourdough needs a starter"], re.findall(r"([^<]*)", self.pop_after("Sourdough needs a starter.", "The starter"))) self.assertEqual(["fed daily"], re.findall(r"([^<]*)", self.pop_after("The starter is", ""))) def test_a_sentence_citing_both_shows_both_quotes_once(self) -> None: self.assertEqual(["Sourdough needs a starter", "fed daily"], re.findall(r"([^<]*)", self.pop_after("A starter", " "))) def test_the_entries_still_share_one_number_and_every_footnote_resolves(self) -> None: refs = dict(re.findall(r']*>(\d+)', self.page)) self.assertEqual(refs["f-starter"], refs["f-daily"]) result = view.check(self.bundle, self.out) self.assertEqual((4, 4), result.per_page["feeding.md"]) def tree_digest(out: Path) -> str: """sha256 over every file of a rendered view: its path, a NUL, its bytes and a NUL, in sorted path order.""" h = hashlib.sha256() for p in sorted(x for x in out.rglob("*") if x.is_file()): h.update(p.relative_to(out).as_posix().encode("utf-8") + b"\0" + p.read_bytes() + b"\0") return h.hexdigest() # The view of the fixtures above as view.py rendered them before wave 2 order 7 (measured on the tree 73bec12): without # --marks the output stays byte for byte the same. DIGEST_BASE = "34fa2414231cd44ca1116bab7d0e492415a58dfe0618a7bbb3ae6de67558e211" DIGEST_ALL = "44f584b4f4f71fade815f41f7f13d4b1aabcb0b8420c9889f2bbfffcdfe810b1" def marks_text(pages: list[dict[str, Any]]) -> str: """A change-marks file in the form of contract K4 (okf-wiki/source-marks/1).""" return json.dumps({"pages": pages, "schema": "okf-wiki/source-marks/1"}, indent=1, sort_keys=True, ensure_ascii=False) + "\n" MARKS = [{"page": "sourdough.md", "sources": [{"change": "changed", "path": "kilde/bread.md"}, {"change": "gone", "path": "kilde/oven.md"}]}] class MarksTest(Fixture): """Contract K4: the change marks of okfwiki's change warning, shown on the pages built on a changed or gone source.""" def marks_file(self, pages: list[dict[str, Any]] | None = None, text: str | None = None) -> Path: path = self.root / "marks.json" path.write_text(marks_text(MARKS if pages is None else pages) if text is None else text, encoding="utf-8") return path def render_marked(self, path: Path) -> None: view.render(self.bundle, self.sources, self.out, marks=view.read_marks(path)) def mark_block(self, page: str) -> str: at = page.index('class="source-mark"') return page[at:page.index("