pantsdown 2.1.0 → 2.1.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 +14 -13
- package/src/lexer.ts +5 -5
- package/src/rules/block.ts +13 -5
- package/src/rules/inline.ts +1 -1
- package/src/tokenizer.ts +3 -1
- package/cz-adapter.cjs +0 -9
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "pantsdown",
|
|
3
3
|
"author": "wallpants",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "2.1.
|
|
5
|
+
"version": "2.1.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Markdown to 'GitHub HTML' parser",
|
|
8
8
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"config": {
|
|
30
30
|
"commitizen": {
|
|
31
|
-
"path": "
|
|
31
|
+
"path": "@commitlint/cz-commitlint"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"commitlint": {
|
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
"scripts": {
|
|
45
45
|
"commit": "cz",
|
|
46
46
|
"format": "prettier **/*.{md,ts,css,yml} -w",
|
|
47
|
-
"
|
|
47
|
+
"typecheck": "tsc",
|
|
48
|
+
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
|
|
49
|
+
"check": "bun run typecheck && bun run lint",
|
|
48
50
|
"docs:build": "bun run docs/build.ts"
|
|
49
51
|
},
|
|
50
52
|
"dependencies": {
|
|
@@ -52,19 +54,18 @@
|
|
|
52
54
|
"highlight.js": "^11.9.0"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@commitlint/config-conventional": "^19.0
|
|
56
|
-
"@commitlint/cz-commitlint": "^19.0
|
|
57
|
-
"@happy-dom/global-registrator": "^
|
|
58
|
-
"@types/bun": "^1.0.
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
60
|
-
"@typescript-eslint/parser": "^7.
|
|
57
|
+
"@commitlint/config-conventional": "^19.1.0",
|
|
58
|
+
"@commitlint/cz-commitlint": "^19.2.0",
|
|
59
|
+
"@happy-dom/global-registrator": "^14.7.1",
|
|
60
|
+
"@types/bun": "^1.0.12",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
62
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
61
63
|
"commitizen": "^4.3.0",
|
|
62
|
-
"commitlint": "^19.0
|
|
64
|
+
"commitlint": "^19.3.0",
|
|
63
65
|
"eslint": "^8.57.0",
|
|
64
|
-
"inquirer": "^9.2.15",
|
|
65
66
|
"prettier": "^3.2.5",
|
|
66
67
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
67
|
-
"semantic-release": "^23.0.
|
|
68
|
-
"typescript": "5.
|
|
68
|
+
"semantic-release": "^23.0.6",
|
|
69
|
+
"typescript": "5.4.5"
|
|
69
70
|
}
|
|
70
71
|
}
|
package/src/lexer.ts
CHANGED
|
@@ -36,10 +36,10 @@ export class Lexer {
|
|
|
36
36
|
|
|
37
37
|
this.blockTokens(src, this.tokens);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
while ((next = this.inlineQueue.shift())) {
|
|
39
|
+
for (const next of this.inlineQueue) {
|
|
41
40
|
this.inlineTokens(next.src, next.tokens);
|
|
42
41
|
}
|
|
42
|
+
this.inlineQueue = [];
|
|
43
43
|
|
|
44
44
|
const footnotesToken: Tokens["Footnotes"] = {
|
|
45
45
|
type: "footnotes",
|
|
@@ -71,7 +71,7 @@ export class Lexer {
|
|
|
71
71
|
* Lexing
|
|
72
72
|
*/
|
|
73
73
|
blockTokens(src: string, tokens: Token[]): Token[] {
|
|
74
|
-
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs: string) => {
|
|
74
|
+
src = src.replace(/^( *)(\t+)/gm, (_, leading: string, tabs: string) => {
|
|
75
75
|
return leading + " ".repeat(tabs.length);
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -228,7 +228,7 @@ export class Lexer {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
if (src) {
|
|
231
|
-
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
231
|
+
const errMsg = "Infinite loop on byte: " + String(src.charCodeAt(0));
|
|
232
232
|
throw new Error(errMsg);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
@@ -401,7 +401,7 @@ export class Lexer {
|
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
if (src) {
|
|
404
|
-
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
404
|
+
const errMsg = "Infinite loop on byte: " + String(src.charCodeAt(0));
|
|
405
405
|
throw new Error(errMsg);
|
|
406
406
|
}
|
|
407
407
|
}
|
package/src/rules/block.ts
CHANGED
|
@@ -25,8 +25,8 @@ const tag =
|
|
|
25
25
|
"|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption" +
|
|
26
26
|
"|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe" +
|
|
27
27
|
"|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option" +
|
|
28
|
-
"|p|param|section|
|
|
29
|
-
"|track|ul";
|
|
28
|
+
"|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title" +
|
|
29
|
+
"|tr|track|ul";
|
|
30
30
|
|
|
31
31
|
const title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
32
32
|
|
|
@@ -49,7 +49,7 @@ const block_list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
|
|
|
49
49
|
.replace("def", "\\n+(?=" + block_def.source + ")")
|
|
50
50
|
.getRegex();
|
|
51
51
|
|
|
52
|
-
export const comment = /<!--(
|
|
52
|
+
export const comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
53
53
|
|
|
54
54
|
const block_html = edit(
|
|
55
55
|
"^ {0,3}(?:" + // optional indentation
|
|
@@ -72,8 +72,16 @@ const block_html = edit(
|
|
|
72
72
|
)
|
|
73
73
|
.getRegex();
|
|
74
74
|
|
|
75
|
-
const block_lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
|
|
75
|
+
// const block_lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
|
|
76
|
+
const block_lheading = edit(
|
|
77
|
+
/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
78
|
+
)
|
|
76
79
|
.replace(/bull/g, block_bullet) // lists can interrupt
|
|
80
|
+
.replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
|
|
81
|
+
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
|
82
|
+
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
|
83
|
+
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
|
84
|
+
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
|
|
77
85
|
.getRegex();
|
|
78
86
|
|
|
79
87
|
const block_hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
@@ -98,7 +106,7 @@ const block_paragraph = edit(
|
|
|
98
106
|
)
|
|
99
107
|
.replace("hr", block_hr)
|
|
100
108
|
.replace("heading", " {0,3}#{1,6}(?:\\s|$)")
|
|
101
|
-
.replace("|lheading", "") //
|
|
109
|
+
.replace("|lheading", "") // setext headings don't interrupt commonmark paragraphs
|
|
102
110
|
.replace("table", block_table) // interrupt paragraphs with table
|
|
103
111
|
.replace("blockquote", " {0,3}>")
|
|
104
112
|
.replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n")
|
package/src/rules/inline.ts
CHANGED
|
@@ -22,7 +22,7 @@ type InlineRuleNames =
|
|
|
22
22
|
| "backpedal";
|
|
23
23
|
|
|
24
24
|
// list of unicode punctuation marks, plus any missing characters from CommonMark spec
|
|
25
|
-
const punctuation = "\\p{P}
|
|
25
|
+
const punctuation = "\\p{P}\\p{S}";
|
|
26
26
|
const title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
27
27
|
const href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
28
28
|
const scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
package/src/tokenizer.ts
CHANGED
|
@@ -105,7 +105,9 @@ export class Tokenizer {
|
|
|
105
105
|
const cap = block.blockquote.exec(src);
|
|
106
106
|
if (!cap) return undefined;
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
// precede setext continuation with 4 spaces so it isn't a setext
|
|
109
|
+
let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1");
|
|
110
|
+
text = rtrim(text.replace(/^ *>[ \t]?/gm, ""), "\n");
|
|
109
111
|
const top = this.lexer.state.top;
|
|
110
112
|
this.lexer.state.top = true;
|
|
111
113
|
const tokens = this.lexer.blockTokens(text, []);
|
package/cz-adapter.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
// this bridge adapter as workaround for ESM version of commitlint
|
|
4
|
-
// https://github.com/conventional-changelog/commitlint/issues/3949
|
|
5
|
-
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
exports.prompter = async (inquirerIns, commit) => {
|
|
8
|
-
(await import("@commitlint/cz-commitlint")).prompter(inquirerIns, commit);
|
|
9
|
-
};
|