-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
The following will fail:
::spantable::
| Foo | Bar |
| --- | --- |
| Baz | `|` |
::end-spantable::One hack is to store temporary replace codes with a placeholder:
--- a/neoteroi/mkdocs/markdown/tables/__init__.py
+++ b/neoteroi/mkdocs/markdown/tables/__init__.py
@@ -115,6 +115,15 @@ def read_table(markdown: str, cls: Type[T] = Table) -> Optional[T]:
records: List[List[str]] = []
for line in markdown.splitlines():
+
+ # Code blocks could contain pipes, so we need to store them and replace them later
+ code = []
+ def store(match):
+ code.append(match.group(0))
+ return f"@@{len(code) - 1}@@"
+
+ line = re.sub(r"`[^`]+`", store, line)
+
if _TABLE_SEPARATOR_LINE_PATTERN.match(line):
continue
@@ -122,6 +131,11 @@ def read_table(markdown: str, cls: Type[T] = Table) -> Optional[T]:
if matches:
row = [match.group(1).strip() for match in matches]
+
+ for i, cell in enumerate(row):
+ row[i] = re.sub(
+ r"@@(\d+)@@", lambda m: code[int(m.group(1))], cell)
+
if not headers:
headers = row
else:Metadata
Metadata
Assignees
Labels
No labels