feat(propose): name the grid-rule grammar Arm E measures
Two constants, no behaviour. `RULE_TABLE_GRID = "rule:table-grid"` joins `RULE_NAMES`, and `_GRID_RULE` sits beside `_TABLE_ROW` as the grammar of a pandoc grid-table rule line. The rule is the author's, not upstream's, and the constant says so: `grep -c -i "arm" docs/2026-09-02-k3-k4-k5-metode.md` is 0, so the definition was written for order 20260907T075834Z-18584396-from-.claude. Its axis is a third one -- Arm C names SIZE, Arm D names what the DOCUMENT declared, and this names what the CONVERTER emitted. The character class `[-=:+]` is measured, not guessed. Across the three grid-bearing documents of the K2 corpus, 38 of 38 lines whose stripped form starts with `+` match this pattern, and those four characters are the complete set occurring on them. The `:` is pandoc's column-alignment marker and is load bearing: a first pass with `[-=+]` matched 37 of 38, and through that single miss read one document as having two tables where it has one. The `\s*` on both ends mirrors `_TABLE_ROW` because the loop iterates `splitlines(keepends=True)` -- every line carries its `\n`, and an indented rule line is a real shape. Tests first: 2 red, then green. 1233 -> 1235. ruff check: exit 0. ruff format --check: exit 0. mypy --strict src/: 17 files, Success. pytest -q: exit 0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
45f1013308
commit
dc67f86511
2 changed files with 57 additions and 0 deletions
|
|
@ -1251,3 +1251,30 @@ def test_the_default_artifact_over_a_grid_table_matches_its_committed_golden(
|
|||
assert out.read_bytes() == golden.read_bytes(), (
|
||||
"the default artifact over a grid table diverges from its committed golden bytes"
|
||||
)
|
||||
|
||||
|
||||
def test_the_grid_rule_name_is_registered() -> None:
|
||||
"""A rule an operator cannot find in `RULE_NAMES` is an unnameable rule."""
|
||||
assert okf_propose_segments.RULE_TABLE_GRID == "rule:table-grid"
|
||||
assert okf_propose_segments.RULE_TABLE_GRID in okf_propose_segments.RULE_NAMES
|
||||
|
||||
|
||||
def test_the_grid_rule_grammar_is_the_class_the_corpus_declared() -> None:
|
||||
"""`[-=:+]`, and the `\\s*` tolerance, are both measured rather than guessed.
|
||||
|
||||
Measured on the three grid-bearing documents of the K2 corpus: 38 of 38
|
||||
lines whose stripped form starts with `+` match this pattern, and the
|
||||
complete character set on those lines is `+`, `-`, `:`, `=`. The `:` is
|
||||
pandoc's column-alignment marker; a first pass with the class `[-=+]`
|
||||
returned 37 and mis-read one document as having two tables instead of one.
|
||||
|
||||
Every input carries its trailing newline, because `find_candidates`
|
||||
iterates `splitlines(keepends=True)` and that is the string the shipped
|
||||
loop actually sees. A stripped-literal test would be green while the rule
|
||||
never fired on an indented or trailing-space rule line.
|
||||
"""
|
||||
grid = okf_propose_segments._GRID_RULE
|
||||
for line in ("+---+---+\n", "+===+===+\n", "+:--+--:+\n", "+---+\n", " +---+---+\n"):
|
||||
assert grid.match(line) is not None, line
|
||||
for line in ("+\n", "++\n", "|---|---|\n", "+--- +---+\n", "---+---\n", "+abc+\n"):
|
||||
assert grid.match(line) is None, line
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue