51 lines
3.2 KiB
Python
51 lines
3.2 KiB
Python
from pathlib import Path
|
|
import re, html
|
|
import markdown
|
|
|
|
src = Path('/home/adolforeyna/brain/projects/livestream_video_generation_process.md')
|
|
out_dir = Path('/home/adolforeyna/brain/exports')
|
|
out_dir.mkdir(parents=True, exist_ok=True)
|
|
text = src.read_text(encoding='utf-8')
|
|
text = re.sub(r'^---\n.*?\n---\n\s*', '', text, flags=re.S)
|
|
text = re.sub(r'^#\s+(.+)$', r'# \1\n\n**Prepared for EMI media/livestream planning** \n**Updated:** June 29, 2026', text, count=1, flags=re.M)
|
|
text = re.sub(r'\[\[([^\]|]+)\|([^\]]+)\]\]', r'\2', text)
|
|
text = re.sub(r'\[\[([^\]]+)\]\]', lambda m: m.group(1).replace('_',' '), text)
|
|
# Python-Markdown needs a blank line before many lists; add one after label lines ending in ':'
|
|
text = re.sub(r'(?m)(^[^\n#][^\n]*:\s*)\n(-\s+)', r'\1\n\n\2', text)
|
|
body = markdown.markdown(text, extensions=['extra','toc','sane_lists','smarty'])
|
|
css = r'''
|
|
@page { size: Letter; margin: 0.65in 0.62in; }
|
|
* { box-sizing: border-box; }
|
|
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #1f2933; line-height: 1.47; font-size: 10.7pt; }
|
|
h1 { font-size: 27pt; color: #12355b; margin: 0 0 8px 0; letter-spacing: -0.02em; padding-bottom: 12px; border-bottom: 4px solid #2f80ed; }
|
|
h2 { font-size: 18pt; color: #12355b; margin-top: 28px; padding: 8px 12px; background: linear-gradient(90deg,#eaf3ff,#ffffff); border-left: 5px solid #2f80ed; break-after: avoid; }
|
|
h3 { font-size: 13.5pt; color: #164b7a; margin-top: 20px; border-bottom: 1px solid #d6e4f0; padding-bottom: 4px; break-after: avoid; }
|
|
h4 { font-size: 11.8pt; color: #2f5f8f; margin-top: 15px; break-after: avoid; }
|
|
p { margin: 7px 0; }
|
|
ul, ol { margin-top: 5px; padding-left: 22px; }
|
|
li { margin: 3px 0; }
|
|
blockquote { margin: 12px 0; padding: 10px 14px; border-left: 4px solid #f2c94c; background: #fff9e6; color: #4a3b00; }
|
|
code { background: #eef4fa; padding: 1px 4px; border-radius: 4px; color: #0b456f; font-family: "SFMono-Regular", Consolas, monospace; font-size: 9pt; }
|
|
table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 8.8pt; page-break-inside: auto; }
|
|
th { background: #12355b; color: white; text-align: left; padding: 7px 6px; }
|
|
td { border: 1px solid #d9e2ec; padding: 6px; vertical-align: top; }
|
|
tr:nth-child(even) td { background: #f7fbff; }
|
|
a { color: #1a73e8; text-decoration: none; }
|
|
hr { border: 0; border-top: 1px solid #d9e2ec; margin: 22px 0; }
|
|
strong { color: #102a43; }
|
|
.title-card { border: 1px solid #d6e4f0; border-radius: 14px; padding: 18px; background: linear-gradient(135deg,#f7fbff,#ffffff); margin-bottom: 18px; }
|
|
.footer-note { margin-top: 28px; font-size: 8.5pt; color: #64748b; border-top: 1px solid #d9e2ec; padding-top: 8px; }
|
|
@media print { h2, h3, h4 { break-after: avoid; } table, blockquote { break-inside: avoid; } }
|
|
'''
|
|
full = f'''<!doctype html>
|
|
<html><head><meta charset="utf-8"><title>Livestream and Video Generation Process</title><style>{css}</style></head>
|
|
<body>
|
|
<div class="title-card">
|
|
{body}
|
|
</div>
|
|
<div class="footer-note">Generated from the Reyna family brain note: {html.escape(str(src))}</div>
|
|
</body></html>'''
|
|
html_path = out_dir / 'livestream_video_generation_process.html'
|
|
html_path.write_text(full, encoding='utf-8')
|
|
print(html_path)
|