@markuplint/pug-parser 4.0.0-alpha.4 → 4.0.0-alpha.6
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/LICENSE +1 -1
- package/lib/attr-tokenizer.d.ts +1 -1
- package/lib/attr-tokenizer.js +13 -16
- package/lib/parse.js +1 -1
- package/lib/pug-parser/index.js +1 -1
- package/package.json +5 -5
package/LICENSE
CHANGED
package/lib/attr-tokenizer.d.ts
CHANGED
package/lib/attr-tokenizer.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { tokenizer, uuid } from '@markuplint/parser-utils';
|
|
2
|
-
export
|
|
1
|
+
import { tokenizer, uuid, scriptParser, removeQuote } from '@markuplint/parser-utils';
|
|
2
|
+
export function attrTokenizer(
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
4
|
attr) {
|
|
5
5
|
if (attr.raw[0] === '#' || attr.raw[0] === '.') {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value = attr.val.match(/(["'`]?)([^\1]+)(\1)/)?.[2] ?? '';
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
value = `${attr.val}`;
|
|
12
|
-
}
|
|
6
|
+
const value = `${attr.val}`;
|
|
7
|
+
const potentialValue = removeQuote(value);
|
|
13
8
|
return {
|
|
14
9
|
type: 'ps-attr',
|
|
15
10
|
uuid: uuid(),
|
|
@@ -21,7 +16,7 @@ attr) {
|
|
|
21
16
|
startCol: attr.column,
|
|
22
17
|
endCol: attr.endColumn,
|
|
23
18
|
potentialName: attr.name,
|
|
24
|
-
potentialValue
|
|
19
|
+
potentialValue,
|
|
25
20
|
valueType: 'string',
|
|
26
21
|
isDuplicatable: attr.raw[0] === '.',
|
|
27
22
|
nodeName: '#pug-special-attr',
|
|
@@ -37,28 +32,29 @@ attr) {
|
|
|
37
32
|
let spacesBeforeEqualChars;
|
|
38
33
|
let equalChars;
|
|
39
34
|
let spacesAfterEqualChars;
|
|
40
|
-
|
|
35
|
+
const quoteChars = '';
|
|
41
36
|
let valueChars;
|
|
37
|
+
let potentialValue;
|
|
42
38
|
let isDynamicValue = undefined;
|
|
43
39
|
if (attr.val === true) {
|
|
44
40
|
spacesBeforeEqualChars = '';
|
|
45
41
|
equalChars = '';
|
|
46
42
|
spacesAfterEqualChars = '';
|
|
47
|
-
quoteChars = '';
|
|
48
43
|
valueChars = '';
|
|
44
|
+
potentialValue = '';
|
|
49
45
|
}
|
|
50
46
|
else {
|
|
51
47
|
const withoutName = attr.raw.slice(attr.name.length);
|
|
52
48
|
const valueOffset = withoutName.indexOf(attr.val);
|
|
53
49
|
const equalAndBeforeSpaceAfterSpace = withoutName.slice(0, valueOffset);
|
|
54
50
|
const [, before, equal, after] = equalAndBeforeSpaceAfterSpace.match(/^(\s*)(=)(\s*)$/) ?? ['', '', '', ''];
|
|
55
|
-
const
|
|
51
|
+
const valueTokens = scriptParser(attr.val);
|
|
56
52
|
spacesBeforeEqualChars = before ?? '';
|
|
57
53
|
equalChars = equal ?? '';
|
|
58
54
|
spacesAfterEqualChars = after ?? '';
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
55
|
+
valueChars = attr.val;
|
|
56
|
+
potentialValue = removeQuote(attr.val);
|
|
57
|
+
if (valueTokens.length > 1 || valueTokens[0].type !== 'String') {
|
|
62
58
|
isDynamicValue = true;
|
|
63
59
|
}
|
|
64
60
|
}
|
|
@@ -127,6 +123,7 @@ attr) {
|
|
|
127
123
|
endQuote,
|
|
128
124
|
isDynamicValue,
|
|
129
125
|
isDuplicatable,
|
|
126
|
+
potentialValue,
|
|
130
127
|
nodeName: name.raw,
|
|
131
128
|
parentNode: null,
|
|
132
129
|
nextNode: null,
|
package/lib/parse.js
CHANGED
|
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _Parser_ast;
|
|
13
13
|
import { getNamespace, parse as htmlParse, isDocumentFragment } from '@markuplint/html-parser';
|
|
14
14
|
import { detectElementType, ignoreFrontMatter, ParserError, tokenizer, uuid, walk, removeDeprecatedNode, } from '@markuplint/parser-utils';
|
|
15
|
-
import attrTokenizer from './attr-tokenizer.js';
|
|
15
|
+
import { attrTokenizer } from './attr-tokenizer.js';
|
|
16
16
|
import { pugParse } from './pug-parser/index.js';
|
|
17
17
|
export const parse = (rawCode, options) => {
|
|
18
18
|
let unknownParseError;
|
package/lib/pug-parser/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/pug-parser",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"description": "Pug parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"clean": "tsc --build --clean"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@markuplint/html-parser": "4.0.0-alpha.
|
|
25
|
-
"@markuplint/ml-ast": "4.0.0-alpha.
|
|
26
|
-
"@markuplint/parser-utils": "4.0.0-alpha.
|
|
24
|
+
"@markuplint/html-parser": "4.0.0-alpha.6",
|
|
25
|
+
"@markuplint/ml-ast": "4.0.0-alpha.6",
|
|
26
|
+
"@markuplint/parser-utils": "4.0.0-alpha.6",
|
|
27
27
|
"pug-lexer": "^5.0.1",
|
|
28
28
|
"pug-parser": "^6.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "06e1242d274c72cf08a10a572b06ac35d1b924a4"
|
|
31
31
|
}
|