@markuplint/parser-utils 4.8.3 → 4.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.8.5](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.8.4...@markuplint/parser-utils@4.8.5) (2025-02-27)
7
+
8
+ **Note:** Version bump only for package @markuplint/parser-utils
9
+
10
+ ## [4.8.4](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.8.3...@markuplint/parser-utils@4.8.4) (2025-02-11)
11
+
12
+ **Note:** Version bump only for package @markuplint/parser-utils
13
+
6
14
  ## [4.8.3](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.8.2...@markuplint/parser-utils@4.8.3) (2025-02-04)
7
15
 
8
16
  ### Bug Fixes
@@ -0,0 +1,2 @@
1
+ import type { MLASTParentNode, NamespaceURI } from '@markuplint/ml-ast';
2
+ export declare function getNamespace(currentNodeName: string | null, parentNode: MLASTParentNode | null): NamespaceURI;
@@ -0,0 +1,29 @@
1
+ export function getNamespace(currentNodeName, parentNode) {
2
+ const parentNS = getParentNamespace(parentNode);
3
+ if (parentNS === 'http://www.w3.org/1999/xhtml' && currentNodeName?.toLowerCase() === 'svg') {
4
+ return 'http://www.w3.org/2000/svg';
5
+ }
6
+ else if (parentNS === 'http://www.w3.org/2000/svg' && parentNode?.nodeName === 'foreignObject') {
7
+ return 'http://www.w3.org/1999/xhtml';
8
+ }
9
+ else if (parentNS === 'http://www.w3.org/1999/xhtml' && currentNodeName?.toLowerCase() === 'math') {
10
+ return 'http://www.w3.org/1998/Math/MathML';
11
+ }
12
+ return parentNS;
13
+ }
14
+ function getParentNamespace(parentNode) {
15
+ if (!parentNode) {
16
+ return 'http://www.w3.org/1999/xhtml';
17
+ }
18
+ if ('namespace' in parentNode && parentNode.namespace) {
19
+ const ns = parentNode.namespace.toLowerCase().trim();
20
+ return ns === 'http://www.w3.org/1999/xhtml'
21
+ ? 'http://www.w3.org/1999/xhtml'
22
+ : ns === 'http://www.w3.org/2000/svg'
23
+ ? 'http://www.w3.org/2000/svg'
24
+ : ns === 'http://www.w3.org/1998/Math/MathML'
25
+ ? 'http://www.w3.org/1998/Math/MathML'
26
+ : 'http://www.w3.org/1999/xhtml';
27
+ }
28
+ return getParentNamespace(parentNode.parentNode);
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/parser-utils",
3
- "version": "4.8.3",
3
+ "version": "4.8.5",
4
4
  "description": "Utility module for markuplint parser plugin",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -30,16 +30,16 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@markuplint/ml-ast": "4.4.9",
33
- "@markuplint/ml-spec": "4.9.2",
34
- "@markuplint/types": "4.7.2",
33
+ "@markuplint/ml-spec": "4.9.4",
34
+ "@markuplint/types": "4.7.4",
35
35
  "@types/uuid": "10.0.0",
36
36
  "debug": "4.4.0",
37
37
  "espree": "10.3.0",
38
- "type-fest": "4.33.0",
39
- "uuid": "11.0.5"
38
+ "type-fest": "4.35.0",
39
+ "uuid": "11.1.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@typescript-eslint/typescript-estree": "8.18.2"
43
43
  },
44
- "gitHead": "687a84e00546b8f1f2ed88125fe507239723c8d8"
44
+ "gitHead": "1b71e44a0a372662abca460ef77888053b66a78d"
45
45
  }