Closed ben519 closed 8 months ago
I don't see why isInlineCode
would be the issue since it checks if there's a pre
parent, and in your AST there is one?
Oops, my mistake. The culprit must be isBlockCode()
export function isBlockCode(element: Element): element is Element {
return (
element.tagName === 'pre' &&
Array.isArray(element.children) &&
element.children.length === 1 &&
isElement(element.children[0]) &&
element.children[0].tagName === 'code'
);
}
Firstly, this package is amazing - thanks for your hard work on it!
I'm using
rehypeKatex
along with this package. InrehypeKatex
(and most other LaTex-like markdown libraries) you denote block-style equations with opening and closing double dollar signs ($$
). For example,This products an AST like this
rehype-pretty-code
then incorrectly assumes this is inline code and styles it accordingly. I believe the definition forisInlineCode
is to blame.As a temporary hack, I can avoid the issue by placing
rehypeKatex
beforerehypePrettyCode
in my processor. But I would rather not do this.Could you alter the definition for
isInlineCode()
to be a little more strict, perhaps confirming that the element className does not include'language-math'
?