fix(docs): recognize RST-style per-column dashed rules as tables
Generate documentation / build-docs (push) Successful in 3m22s

_as_ruled_table() only matched a single solid run of dashes under the
header row. The "Fish Universal Variables" table in
07-customization.md uses the other common convention instead: one
dash run per column, gapped the same as the header (RST simple-table
style) — e.g. "------  ----------". That line failed RULE_RE's
whole-line match, so the table still fell through to a code block.

Split the rule line on the same CELL_SPLIT boundary used for data
rows and require every resulting group to be a solid dash run, which
accepts both conventions without adding a second code path.

No SSOT changes needed — the source table was already well-formed,
docs/fish-config.md round-trips unchanged, confirming this is a
site-only fix.
This commit is contained in:
2026-07-26 16:06:36 -04:00
parent 980834e961
commit 4ca008836c
2 changed files with 25 additions and 5 deletions
+8 -5
View File
@@ -214,11 +214,11 @@ FILENAME_COMMENT_RE = re.compile(r"^#\s*(?:in\s+)?([\w-]+\.\w+)\s*$")
CELL_SPLIT = re.compile(r"\s{2,}")
# A solid rule line under a header row — the "Component Reference" tables'
# A rule line under a header row — the "Component Reference" tables'
# authoring convention (header, dashes, data rows all at the same indent,
# no ":"-terminated label). Distinct enough from CELL_SPLIT-based prose that
# it needs its own check rather than overloading _as_table's indent rule.
RULE_RE = re.compile(r"^[─\-]{10,}$")
# no ":"-terminated label). Either one solid run of dashes, or (RST-style)
# one dash run per column, gapped the same way CELL_SPLIT splits cells.
RULE_CELL_RE = re.compile(r"^[─\-]{3,}$")
def _cell(text: str, code: bool) -> str:
@@ -280,7 +280,10 @@ def _as_ruled_table(para: list[str]) -> str | None:
else that doesn't match the header's column count is a source alignment
bug, so bail out to the code-block fallback rather than guess.
"""
if len(para) < 4 or not RULE_RE.match(para[1].strip()):
if len(para) < 4:
return None
rule_cells = CELL_SPLIT.split(para[1].strip())
if not all(RULE_CELL_RE.match(cell) for cell in rule_cells):
return None
header = CELL_SPLIT.split(para[0].strip())
n = len(header)