@markuplint/parser-utils 2.2.2 → 2.2.4-canary.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/parser-utils",
|
|
3
|
-
"version": "2.2.2",
|
|
3
|
+
"version": "2.2.4-canary.2+2da869d4",
|
|
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>",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"@types/uuid": "^8.3.4"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@markuplint/ml-ast": "2.0.1-
|
|
23
|
-
"@markuplint/types": "2.2.
|
|
22
|
+
"@markuplint/ml-ast": "2.0.1-canary.66+2da869d4",
|
|
23
|
+
"@markuplint/types": "2.2.2-canary.2+2da869d4",
|
|
24
24
|
"tslib": "^2.3.1",
|
|
25
25
|
"uuid": "^8.3.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "2da869d44b1bfb11d1fe07c7fbefeea8c1fd298b"
|
|
28
28
|
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectElementType = void 0;
|
|
4
|
-
const decision_1 = require("./decision");
|
|
5
|
-
function detectElementType(name, option, defaultPattern) {
|
|
6
|
-
if (distinguishAuthoredName(name, option, defaultPattern)) {
|
|
7
|
-
return 'authored';
|
|
8
|
-
}
|
|
9
|
-
return (0, decision_1.isPotentialCustomElementName)(name) ? 'web-component' : 'html';
|
|
10
|
-
}
|
|
11
|
-
exports.detectElementType = detectElementType;
|
|
12
|
-
function distinguishAuthoredName(name, pattern, defaultPattern) {
|
|
13
|
-
if (pattern) {
|
|
14
|
-
return _distinguishAuthoredName(name, pattern);
|
|
15
|
-
}
|
|
16
|
-
if (defaultPattern) {
|
|
17
|
-
return _distinguishAuthoredName(name, defaultPattern);
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
function _distinguishAuthoredName(name, patterns) {
|
|
22
|
-
const patternList = Array.isArray(patterns) ? patterns : [patterns];
|
|
23
|
-
return patternList.some(pattern => {
|
|
24
|
-
if (typeof pattern === 'function') {
|
|
25
|
-
return pattern(name);
|
|
26
|
-
}
|
|
27
|
-
const regex = typeof pattern === 'string' ? toRegexp(pattern) : pattern;
|
|
28
|
-
return regex.test(name);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function toRegexp(pattern) {
|
|
32
|
-
const matched = pattern.match(/^\/(.+)\/([ig]*)$/i);
|
|
33
|
-
if (matched) {
|
|
34
|
-
return new RegExp(matched[1], matched[2]);
|
|
35
|
-
}
|
|
36
|
-
return new RegExp(pattern);
|
|
37
|
-
}
|