docs: use indented text tables for abbreviations and strip CardGrid from concat
This commit is contained in:
@@ -55,14 +55,17 @@ def _with_abbreviations(body: str, abbrs: dict[str, list[dict]]) -> str:
|
|||||||
"""Inject generated abbreviation tables into the document placeholders."""
|
"""Inject generated abbreviation tables into the document placeholders."""
|
||||||
rendered_abbrs = {}
|
rendered_abbrs = {}
|
||||||
for cat, items in abbrs.items():
|
for cat, items in abbrs.items():
|
||||||
lines_cat = ["| Abbreviation | Description |", "|---|---|"]
|
lines_cat = [" Abbreviation Description", " ───────────────────────────────────────────────────────────────────"]
|
||||||
for abbr in items:
|
for abbr in items:
|
||||||
name = abbr["name"]
|
name = abbr["name"]
|
||||||
desc = abbr["desc"]
|
desc = abbr["desc"]
|
||||||
# Escape pipes if any exist in name or desc
|
|
||||||
name = name.replace("|", "\\|")
|
# Left-pad description to ensure at least 2 spaces for cell split
|
||||||
desc = desc.replace("|", "\\|")
|
name_part = name.ljust(16)
|
||||||
lines_cat.append(f"| `{name}` | {desc} |")
|
if len(name_part) < len(name) + 2:
|
||||||
|
name_part = name + " "
|
||||||
|
|
||||||
|
lines_cat.append(f" {name_part}{desc}")
|
||||||
rendered_abbrs[cat] = "\n".join(lines_cat)
|
rendered_abbrs[cat] = "\n".join(lines_cat)
|
||||||
|
|
||||||
for cat, table in rendered_abbrs.items():
|
for cat, table in rendered_abbrs.items():
|
||||||
@@ -103,6 +106,7 @@ def build_concat(root: Path) -> str:
|
|||||||
body = _with_abbreviations(body, abbrs)
|
body = _with_abbreviations(body, abbrs)
|
||||||
if body:
|
if body:
|
||||||
body = re.sub(r"<LinkButton.*?</LinkButton>\n*", "", body, flags=re.DOTALL)
|
body = re.sub(r"<LinkButton.*?</LinkButton>\n*", "", body, flags=re.DOTALL)
|
||||||
|
body = re.sub(r"<CardGrid.*?</CardGrid>\n*", "", body, flags=re.DOTALL)
|
||||||
body = re.sub(r"\[([^\]]+)\]\(/[^)]+\)", r"\1", body)
|
body = re.sub(r"\[([^\]]+)\]\(/[^)]+\)", r"\1", body)
|
||||||
chunks.append(mt.shift_headings(body, depth))
|
chunks.append(mt.shift_headings(body, depth))
|
||||||
return "\n\n".join(chunks) + "\n"
|
return "\n\n".join(chunks) + "\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user