renderHtml function
Renders highlighted lines as a <pre> block with inline styles, in the
same shape as Shiki's codeToHtml.
Implementation
String renderHtml(List<List<ThemedToken>> lines, SyntaxTheme theme) {
final out = StringBuffer()
..write('<pre class="syntax ${_escape(theme.name)}" style="')
..write('background-color:${colorToHex(theme.background)};')
..write('color:${colorToHex(theme.foreground)}"><code>');
for (var i = 0; i < lines.length; i++) {
if (i > 0) out.write('\n');
out.write('<span class="line">');
for (final token in lines[i]) {
out
..write('<span style="')
..write(_css(token.style))
..write('">')
..write(_escape(token.text))
..write('</span>');
}
out.write('</span>');
}
out.write('</code></pre>');
return out.toString();
}