Skip to content

Commit 8ca49ef

Browse files
fweikertcopybara-github
authored andcommitted
Bazel Docs: Remove trailing whitespaces from generated .mdx files.
PiperOrigin-RevId: 865495082 Change-Id: I6b5d3bf6828ac66129b87d5d0da41dbfaf0a6666
1 parent 1329def commit 8ca49ef

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/docs/html2mdx.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ def _html2md(content):
8989
def _fix_markdown(content):
9090
no_templates = _TEMPLATE_RE.sub("", content)
9191
no_html_links = _HTML_LINK_RE.sub(_fix_link, no_templates)
92-
return _HEADING_RE.sub("---\ntitle: '\\1'\n---", no_html_links)
92+
fixed_headings = _HEADING_RE.sub("---\ntitle: '\\1'\n---", no_html_links)
93+
return _remove_trailing_whitespaces(fixed_headings)
94+
95+
96+
def _remove_trailing_whitespaces(content):
97+
lines = (l.rstrip() for l in content.split("\n"))
98+
return "\n".join(lines)
9399

94100

95101
def _fix_link(m):

0 commit comments

Comments
 (0)