Sometimes, hljs generates text nodes that are direct descendents of a code element, without being the children of a span. rehype-hljs-var expects all text nodes to be the sole children of an element node.
This change edits rehype-hljs-var to accommodate text nodes. It also refactors the plugin to clean up the logic for splitting text nodes with Var component placeholders.
Sometimes, hljs generates text nodes that are direct descendents of a
code
element, without being the children of aspan
. rehype-hljs-var expects all text nodes to be the sole children of an element node.This change edits rehype-hljs-var to accommodate text nodes. It also refactors the plugin to clean up the logic for splitting text nodes with Var component placeholders.