Expand description
HTML renderer for ChordPro documents.
Converts a parsed ChordPro AST into either a self-contained HTML5 document
(with embedded CSS) or a body-only <div class="song"> fragment suitable
for embedding in a host document. Use render_song / render_songs
for the full-document API and render_song_body / render_songs_body
for the fragment API. Pair the latter with render_html_css to obtain
the matching stylesheet.
§Security
Delegate section environments ({start_of_svg}, {start_of_abc},
{start_of_ly}, {start_of_textblock}) emit their content as raw,
unescaped HTML. This is by design per the ChordPro specification, as these
sections contain verbatim markup (e.g., inline SVG).
SVG sections are sanitized by default: <script> elements and event
handler attributes (onload, onerror, etc.) are stripped to prevent
XSS. When rendering untrusted ChordPro input, consumers should still
apply Content Security Policy (CSP) headers as additional defense.
Constants§
- MAX_
WARNINGS - Maximum number of warnings the renderer accumulates per render pass.
Re-exported from
chordsketch-chordpro::render_resultso callers can keep importingchordsketch_render_html::MAX_WARNINGSunchanged (issue #1874). Maximum number of warnings any renderer accumulates for a single render pass (issue #1833). Without a cap, a pathological input such as one million malformed{transpose}lines would push the warnings vector to tens of megabytes.push_warningrefuses to exceed this limit and appends a single truncation marker the first time the cap is hit.
Functions§
- render
- Parse a ChordPro source string and render it to HTML.
- render_
html_ css - The canonical chord-over-lyrics CSS that the full-document renderers
embed inside
<style>. - render_
html_ css_ with_ config - Variant of
render_html_cssthat honourssettings.wraplinesfrom the supplied config (R6.100.0). Whenwraplinesis false, the.linerule emitsflex-wrap: nowrapso chord/lyric runs that exceed the viewport width preserve the source line structure instead of reflowing. - render_
song - Render a
SongAST to an HTML5 document string. - render_
song_ body - Render a
SongAST to its body-only HTML fragment. - render_
song_ body_ with_ transpose - Render a
SongAST to its body-only HTML fragment with a CLI transposition offset. - render_
song_ body_ with_ warnings - Render a
SongAST to its body-only HTML fragment, returning warnings programmatically. - render_
song_ with_ transpose - Render a
SongAST to an HTML5 document with an additional CLI transposition offset. - render_
song_ with_ warnings - Render a
SongAST to an HTML5 document, returning warnings programmatically. - render_
songs - Render multiple
Songs into a single HTML5 document. - render_
songs_ body - Render multiple
Songs into a single body-only HTML fragment. - render_
songs_ body_ with_ transpose - Render multiple
Songs into a single body-only HTML fragment with transposition. - render_
songs_ body_ with_ warnings - Render multiple
Songs into a single body-only HTML fragment, returning warnings programmatically. - render_
songs_ with_ transpose - Render multiple
Songs into a single HTML5 document with transposition. - render_
songs_ with_ warnings - Render multiple
Songs into a single HTML5 document, returning warnings programmatically. - try_
render - Parse a ChordPro source string and render it to HTML.