Give Blogger tables inline borders

Blogger themes ship no table styling, so the quote tables rendered as
borderless text. Inline styles survive every theme and the mobile view.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jsahn
2026-09-01 14:20:41 +09:00
co-authored by Claude Fable 5
parent 830e4e0522
commit 3ee37bfa49
2 changed files with 19 additions and 2 deletions
+4 -1
View File
@@ -91,7 +91,10 @@ def test_briefing_html_drops_h1_and_renders_tables():
assert "미국 마감 브리핑 — 2026-09-01" not in html # H1 is the post title, not body
assert "<h2>총평</h2>" in html
assert "<strong>하락 마감</strong>" in html
assert "<table>" in html and "<td>7,686.42</td>" in html
# tables carry inline borders - Blogger themes style nothing themselves
assert '<table style="border-collapse:collapse' in html
assert ">7,686.42</td>" in html and 'border:1px solid #ccc' in html
assert "<table>" not in html and "<td>" not in html # every cell got the inline style
def test_post_title_with_and_without_headline():
+15 -1
View File
@@ -28,6 +28,17 @@ TOKEN_SAFETY_MARGIN_SECONDS = 60.0
_MD = md.Markdown(extensions=["tables"], output_format="html")
# Blogger themes ship no <table> styling, so the numbers render as a borderless jumble.
# Inline styles are the only thing every theme (and the mobile view) reliably honors.
_TABLE_STYLES: tuple[tuple[str, str], ...] = (
("<table>", '<table style="border-collapse:collapse;margin:10px 0;">'),
(
"<th>",
'<th style="border:1px solid #ccc;padding:4px 10px;background:#f2f2f2;text-align:left;">',
),
("<td>", '<td style="border:1px solid #ccc;padding:4px 10px;white-space:nowrap;">'),
)
def briefing_html(markdown_text: str) -> str:
"""Briefing markdown -> HTML body. The leading H1 is dropped (the post title carries it)."""
@@ -35,7 +46,10 @@ def briefing_html(markdown_text: str) -> str:
if lines and lines[0].startswith("# "):
lines = lines[1:]
_MD.reset() # the converter keeps per-document state (e.g. reference links)
return _MD.convert("\n".join(lines).strip())
html = _MD.convert("\n".join(lines).strip())
for plain, styled in _TABLE_STYLES:
html = html.replace(plain, styled)
return html
def post_title_prefix(result: BriefingResult) -> str: