Render a post's Markdown to HTML for grammar checks. Strips YAML front matter defensively (so callers may pass either the body or the whole file — front matter must never reach the prose checkers) and Hugo shortcodes, then renders. Imports python-markdown lazily so the dependency-fr
(body)
| 80 | |
| 81 | |
| 82 | def body_to_html(body): |
| 83 | """Render a post's Markdown to HTML for grammar checks. |
| 84 | |
| 85 | Strips YAML front matter defensively (so callers may pass either the body or |
| 86 | the whole file — front matter must never reach the prose checkers) and Hugo |
| 87 | shortcodes, then renders. Imports python-markdown lazily so the |
| 88 | dependency-free paragraph check does not require it. fenced_code/tables |
| 89 | produce <pre><code> and <table> markup that run_languagetool.py skips. |
| 90 | """ |
| 91 | import markdown # lazy: only render paths need it |
| 92 | |
| 93 | _fm, body, _start = split_front_matter(body) |
| 94 | return markdown.markdown( |
| 95 | strip_shortcodes(author_body(body)), |
| 96 | extensions=["fenced_code", "tables"], |
| 97 | ) |
no test coverage detected