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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user