[Feature] Ability to extend HTML renderer
butschster opened this issue · 1 comments
butschster commented
There is only one way to increase amount of elements in termwind - Add PRs with new features.
But sometimes requires an ability to extend HtmlRenderer for specific project.
Something like this
HtmlRenderer::extend('code', static function(\DOMNode $node): Raw {
$highlighter = new Highlighter();
$line = (int) $node->getAttribute('line');
$html = array_reduce(
iterator_to_array($node->childNodes),
static fn(string $html, \DOMNode $child) => $html .= $child->ownerDocument->saveXML($child),
''
);
$html = html_entity_decode($html);
return Termwind::raw(
$highlighter->highlight(html_entity_decode($html), $line)
);
});
As you understood, this package fits me on 100%. I have a pet project where one of the features is rendering debug output into a terminal and I have a lot of legacy code I'm trying to move to this package.
nunomaduro commented
No plans for this.