|
8 | 8 |
|
9 | 9 | ROOT = Path(__file__).resolve().parent |
10 | 10 | LANGS = ("en", "fa", "ar", "tr") |
| 11 | +GITHUB = "https://github.com/iPmartNetwork/VortexUI/blob/master" |
11 | 12 |
|
12 | 13 | ALERT_MAP = { |
13 | 14 | "NOTE": "note", |
@@ -90,6 +91,21 @@ def fix_admonition_quotes(text: str) -> str: |
90 | 91 | return "\n".join(out) |
91 | 92 |
|
92 | 93 |
|
| 94 | +def fix_external_links(text: str) -> str: |
| 95 | + """Point repo-root references at GitHub (outside docs_dir).""" |
| 96 | + replacements = { |
| 97 | + "../../openapi.yaml": f"{GITHUB}/docs/openapi.yaml", |
| 98 | + "../../protocols.md": f"{GITHUB}/docs/protocols.md", |
| 99 | + "../../../.env.example": f"{GITHUB}/.env.example", |
| 100 | + "../../../SECURITY.md": f"{GITHUB}/SECURITY.md", |
| 101 | + "../../../CONTRIBUTING.md": f"{GITHUB}/CONTRIBUTING.md", |
| 102 | + "../../../CHANGELOG.md": f"{GITHUB}/CHANGELOG.md", |
| 103 | + } |
| 104 | + for old, new in replacements.items(): |
| 105 | + text = text.replace(old, new) |
| 106 | + return text |
| 107 | + |
| 108 | + |
93 | 109 | def simplify_nav_line(text: str) -> str: |
94 | 110 | # MkDocs has sidebar; drop redundant breadcrumb nav lines |
95 | 111 | text = re.sub( |
@@ -178,6 +194,7 @@ def sanitize_chapter(path: Path) -> None: |
178 | 194 | text = github_alerts_to_material(text) |
179 | 195 | text = fix_admonition_quotes(text) |
180 | 196 | text = simplify_nav_line(text) |
| 197 | + text = fix_external_links(text) |
181 | 198 | text = ensure_table_spacing(text) |
182 | 199 | text = re.sub(r"\n{3,}", "\n\n", text).strip() + "\n" |
183 | 200 | path.write_text(text, encoding="utf-8") |
|
0 commit comments