pantsdown 2.0.4 → 2.0.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/README.md +2 -2
- package/package.json +6 -6
- package/src/parser.ts +5 -5
- package/src/rules/inline.ts +0 -6
- package/src/rules/utils.ts +5 -5
- package/src/tokenizer.ts +8 -6
package/README.md
CHANGED
|
@@ -145,5 +145,5 @@ console.log(html);
|
|
|
145
145
|
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
|
|
146
146
|
</a>
|
|
147
147
|
|
|
148
|
-
Pantsdown is based on [Marked](https://github.com/markedjs/marked).
|
|
149
|
-
|
|
148
|
+
Pantsdown is based on [Marked](https://github.com/markedjs/marked). Without their hard work,
|
|
149
|
+
Pantsdown would not exist.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantsdown",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"author": "wallpants",
|
|
5
5
|
"description": "Markdown to 'GitHub HTML' parser",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"highlight.js": "^11.9.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@happy-dom/global-registrator": "^
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
47
|
-
"@typescript-eslint/parser": "^6.
|
|
45
|
+
"@happy-dom/global-registrator": "^13.3.1",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
47
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
48
48
|
"bun-types": "latest",
|
|
49
49
|
"commitizen": "^4.3.0",
|
|
50
50
|
"cz-conventional-changelog": "^3.3.0",
|
|
51
51
|
"eslint": "^8.56.0",
|
|
52
|
-
"prettier": "^3.
|
|
52
|
+
"prettier": "^3.2.4",
|
|
53
53
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
54
|
-
"semantic-release": "^
|
|
54
|
+
"semantic-release": "^23.0.0",
|
|
55
55
|
"typescript": "5.3.3"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/parser.ts
CHANGED
|
@@ -109,13 +109,13 @@ export class Parser {
|
|
|
109
109
|
item.tokens.length > 0 &&
|
|
110
110
|
item.tokens[0]!.type === "paragraph"
|
|
111
111
|
) {
|
|
112
|
-
item.tokens[0]
|
|
112
|
+
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
113
113
|
if (
|
|
114
|
-
item.tokens[0]
|
|
115
|
-
item.tokens[0]
|
|
114
|
+
item.tokens[0].tokens.length > 0 &&
|
|
115
|
+
item.tokens[0].tokens[0]!.type === "text"
|
|
116
116
|
) {
|
|
117
|
-
item.tokens[0]
|
|
118
|
-
checkbox + " " + item.tokens[0]
|
|
117
|
+
item.tokens[0].tokens[0]!.text =
|
|
118
|
+
checkbox + " " + item.tokens[0].tokens[0]!.text;
|
|
119
119
|
}
|
|
120
120
|
} else {
|
|
121
121
|
item.tokens.unshift({
|
package/src/rules/inline.ts
CHANGED
|
@@ -18,7 +18,6 @@ type InlineRuleNames =
|
|
|
18
18
|
| "anyPunctuation"
|
|
19
19
|
| "punctuation"
|
|
20
20
|
| "blockSkip"
|
|
21
|
-
| "escapes"
|
|
22
21
|
| "footnoteRef"
|
|
23
22
|
| "backpedal";
|
|
24
23
|
|
|
@@ -66,10 +65,6 @@ const inline_anyPunctuation = edit(/\\[punct]/g, "gu")
|
|
|
66
65
|
.replace(/punct/g, punctuation)
|
|
67
66
|
.getRegex();
|
|
68
67
|
|
|
69
|
-
const inline_escapes = edit(/\\([punct])/g, "gu")
|
|
70
|
-
.replace(/punct/g, punctuation)
|
|
71
|
-
.getRegex();
|
|
72
|
-
|
|
73
68
|
const inline_autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
|
|
74
69
|
.replace("scheme", scheme)
|
|
75
70
|
.replace("email", email)
|
|
@@ -142,7 +137,6 @@ export const inline: Omit<Record<InlineRuleNames, RegExp>, "emStrong"> & {
|
|
|
142
137
|
text: inline_text,
|
|
143
138
|
punctuation: inline_punctuation,
|
|
144
139
|
blockSkip: inline_blockSkip,
|
|
145
|
-
escapes: inline_escapes,
|
|
146
140
|
backpedal: inline_backpedal,
|
|
147
141
|
footnoteRef: /^\[\^([^\]\n]+)\]/,
|
|
148
142
|
};
|
package/src/rules/utils.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const caret = /(^|[^\[])\^/g;
|
|
2
2
|
|
|
3
3
|
export function edit(rule: RegExp | string, opt?: string) {
|
|
4
|
-
|
|
4
|
+
let source = typeof rule === "string" ? rule : rule.source;
|
|
5
5
|
opt = opt ?? "";
|
|
6
6
|
const obj = {
|
|
7
7
|
replace: (name: string | RegExp, val: string | RegExp) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
let valSource = typeof val === "string" ? val : val.source;
|
|
9
|
+
valSource = valSource.replace(caret, "$1");
|
|
10
|
+
source = source.replace(name, valSource);
|
|
11
11
|
return obj;
|
|
12
12
|
},
|
|
13
13
|
getRegex: () => {
|
|
14
|
-
return new RegExp(
|
|
14
|
+
return new RegExp(source, opt);
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
return obj;
|
package/src/tokenizer.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class Tokenizer {
|
|
|
60
60
|
return {
|
|
61
61
|
type: "code",
|
|
62
62
|
raw,
|
|
63
|
-
lang: cap[2] ? cap[2].trim().replace(inline.
|
|
63
|
+
lang: cap[2] ? cap[2].trim().replace(inline.anyPunctuation, "$1") : cap[2],
|
|
64
64
|
text,
|
|
65
65
|
sourceMap: this.lexer.getSourceMap(raw),
|
|
66
66
|
};
|
|
@@ -461,9 +461,11 @@ export class Tokenizer {
|
|
|
461
461
|
if (!cap) return undefined;
|
|
462
462
|
|
|
463
463
|
const tag = cap[1]!.toLowerCase().replace(/\s+/g, " ");
|
|
464
|
-
const href = cap[2]
|
|
464
|
+
const href = cap[2]
|
|
465
|
+
? cap[2].replace(/^<(.*)>$/, "$1").replace(inline.anyPunctuation, "$1")
|
|
466
|
+
: "";
|
|
465
467
|
const title = cap[3]
|
|
466
|
-
? cap[3].substring(1, cap[3].length - 1).replace(inline.
|
|
468
|
+
? cap[3].substring(1, cap[3].length - 1).replace(inline.anyPunctuation, "$1")
|
|
467
469
|
: "";
|
|
468
470
|
return {
|
|
469
471
|
type: "def",
|
|
@@ -667,8 +669,8 @@ export class Tokenizer {
|
|
|
667
669
|
return outputLink(
|
|
668
670
|
cap,
|
|
669
671
|
{
|
|
670
|
-
href: href ? href.replace(inline.
|
|
671
|
-
title: title ? title.replace(inline.
|
|
672
|
+
href: href ? href.replace(inline.anyPunctuation, "$1") : href,
|
|
673
|
+
title: title ? title.replace(inline.anyPunctuation, "$1") : title,
|
|
672
674
|
},
|
|
673
675
|
cap[0],
|
|
674
676
|
this.lexer,
|
|
@@ -755,7 +757,7 @@ export class Tokenizer {
|
|
|
755
757
|
// Remove extra characters. *a*** -> *a*
|
|
756
758
|
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
757
759
|
// char length can be >1 for unicode characters;
|
|
758
|
-
const lastCharLength = [...match[0]]
|
|
760
|
+
const lastCharLength = [...match[0]][0]!.length;
|
|
759
761
|
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
760
762
|
|
|
761
763
|
// Create `em` if smallest delimiter has odd char count. *a***
|