fix(okf-check): treat a cite line range as a reading aid, not a symbol
A `path:92-97` cite fell through the `isdigit()` suffix rule and was matched as a literal symbol, so it could never resolve. Line ranges are the same reading aid a bare line number is, and are idiomatic in this repo prose, so the grammar now admits `N` and `N-M` alike.
This commit is contained in:
parent
6cb19302ea
commit
aa61a3f51f
@ -47,7 +47,8 @@ loop, not on disk.
|
||||
`path:symbol`; all three resolve only if the path exists. `path:symbol`
|
||||
additionally needs the symbol as a literal substring of the file — that
|
||||
is the shape that breaks when the thing it cites moves. A `path:line`
|
||||
number is a reading aid, never validated.
|
||||
suffix — one number or a `92-97` range — is a reading aid, never
|
||||
validated.
|
||||
- **Derived zone** — a page carries at most one region delimited by
|
||||
`<!-- okf:derived begin -->` and `<!-- okf:derived end -->`, each marker
|
||||
alone on its line. Refresh regenerates the inside wholesale and may not
|
||||
|
||||
@ -17,6 +17,7 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
CAP = 110
|
||||
LINE_SUFFIX = re.compile(r"\d+(-\d+)?")
|
||||
|
||||
|
||||
def frontmatter(text):
|
||||
@ -94,14 +95,14 @@ def cite_resolves(cite, page, okf):
|
||||
"""`path` and `path:line` need the path; `path:symbol` needs both.
|
||||
|
||||
The symbol is matched as a literal substring — no language awareness,
|
||||
no tags file. A `:suffix` that parses as an integer is a reading aid,
|
||||
never validated: a check that cannot fail is not a check.
|
||||
no tags file. A `:suffix` that is a line number or a line range is a
|
||||
reading aid, never validated: a check that cannot fail is not a check.
|
||||
"""
|
||||
path, _, symbol = cite.split("#")[0].partition(":")
|
||||
path, symbol = path.strip(), symbol.strip()
|
||||
if not path:
|
||||
return False
|
||||
if symbol.isdigit():
|
||||
if LINE_SUFFIX.fullmatch(symbol):
|
||||
symbol = ""
|
||||
for root in (page.parent, okf, okf.parent):
|
||||
target = root / path
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user