# Cron HTML Rendering & Fallback Notes

## Dependency-free Markdown-to-HTML
- Third-party `markdown` conversion is often unavailable. Use a simple HTML wrapper that preserves existing `<table>` blocks and converts headings/paragraphs explicitly.
- Always verify the rendered output contains the expected table row tag `<tr>` before sending. If absent, treat HTML delivery as failed and either repair or send plain text.
- Preserve theme sections and keep table cells limited to 300–320 chars. Do not emit raw markdown markers when the target is HTML.

## Scripts and escaping in `/tmp`
- Cron shells may forbid inline `python3 -c` and `cat | python`. Prefer `write_file` to `/tmp/<name>.py`, then `terminal /usr/bin/python3 /tmp/<name>.py`.
- Parallel agents may inherit earlier escape patterns in `/tmp`. When updating a script, do **not** shorten existing escaped regexes; preserve the working format to avoid regressions.
- If a script path might be shared by sibling agents, include a unique suffix (PID or UUID). If another process reports modifying the same file, read it first, then overwrite intentionally.

## Placeholder detection
- If fallback generates placeholder repo entries, deliver explicitly as "partial result" instead of silently filling with identical placeholders until reaching 10 rows.
- Validate final report metadata: at least one GitHub link, at least one numbered item, and no repeated placeholder row.

## Recipient discovery in cron
- Job config may omit the email recipient. Before sending, read the cron definition file to recover `deliver` / `origin` fields (e.g., `chat_id`, `email`).
- If `gmail` is not connected but `googlesuper` is active, use the `googlesuper` account email as sender; prefer it over retrying Gmail.
- When Gmail/GSuite tools report no active connection, fall back to GOOGLESUPER_SEND_EMAIL. Ensure is_html=true and body is a real HTML document.
