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

Function normalize_row

scripts/fix_markdown_tables.py:37–51  ·  view source on GitHub ↗

Normalize a table row to have leading/trailing pipes.

(line: str, expected_cols: int = 0)

Source from the content-addressed store, hash-verified

35
36
37def normalize_row(line: str, expected_cols: int = 0) -> str:
38 """Normalize a table row to have leading/trailing pipes."""
39 stripped = line.strip().rstrip(" ")
40 # Remove existing leading/trailing pipes
41 if stripped.startswith("|"):
42 stripped = stripped[1:]
43 if stripped.endswith("|"):
44 stripped = stripped[:-1]
45 cells = [c.strip() for c in stripped.split("|")]
46 # Pad or trim to expected column count if specified
47 if expected_cols > 0:
48 while len(cells) < expected_cols:
49 cells.append("")
50 cells = cells[:expected_cols]
51 return "| " + " | ".join(cells) + " |"
52
53
54def normalize_separator(line: str, expected_cols: int = 0) -> str:

Callers 1

fix_tables_in_contentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected