MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / main

Function main

scripts/fix_markdown_tables.py:141–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139
140
141def main():
142 repo_root = Path(__file__).resolve().parent.parent
143 scan_dirs = [
144 repo_root / "docs" / "zh" / "insights",
145 repo_root / "docs" / "zh" / "nmpa" / "guidance",
146 repo_root / "docs" / "zh" / "nmpa" / "regulations",
147 ]
148
149 dry_run = "--dry-run" in sys.argv
150 fixed_count = 0
151
152 for scan_dir in scan_dirs:
153 if not scan_dir.exists():
154 continue
155 for md_file in scan_dir.rglob("*.md"):
156 content = md_file.read_text(encoding="utf-8")
157 # Quick check: does file have broken tables?
158 if not re.search(r'^---\|', content, re.MULTILINE):
159 continue
160
161 fixed = fix_tables_in_content(content)
162 if fixed != content:
163 fixed_count += 1
164 if dry_run:
165 print(f"[DRY-RUN] Would fix: {md_file.relative_to(repo_root)}")
166 else:
167 md_file.write_text(fixed, encoding="utf-8")
168 print(f"[FIXED] {md_file.relative_to(repo_root)}")
169
170 print(f"\nTotal: {fixed_count} files {'would be ' if dry_run else ''}fixed")
171
172
173if __name__ == "__main__":

Callers 1

Calls 2

fix_tables_in_contentFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected