Skip to content

Commit

Permalink
support math namespaceURI
Browse files Browse the repository at this point in the history
  • Loading branch information
ECorreia45 committed Dec 29, 2024
1 parent be312c9 commit cc57a56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beforesemicolon/html-parser",
"version": "0.6.0",
"version": "0.7.0",
"description": "HTML parser for any Javascript runtime environment",
"type": "module",
"types": "./dist/types/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type NodeHandlerCallback = (node: ElementLike | NodeLike) => void
const NSURI: Record<string, string> = {
HTML: 'http://www.w3.org/1999/xhtml',
SVG: 'http://www.w3.org/2000/svg',
MATH: 'http://www.w3.org/1998/Math/MathML',
}

const setAttributes = (node: Element | ElementLike, attributes: string) => {
Expand Down Expand Up @@ -103,6 +104,8 @@ export const parse = <D extends Partial<DocumentLike | Document>>(

const ns = /svg/i.test(tagName)
? NSURI.SVG
: /math/i.test(tagName)
? NSURI.MATH
: /html/i.test(tagName)
? NSURI.HTML
: (stackLastItem as ElementLike)?.namespaceURI ?? NSURI.HTML
Expand Down

0 comments on commit cc57a56

Please sign in to comment.