pantsdown 2.0.3 → 2.0.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/README.md +2 -2
- package/package.json +7 -7
- package/src/rules/inline.ts +0 -6
- package/src/rules/utils.ts +5 -5
- package/src/tokenizer.ts +7 -5
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.5",
|
|
4
4
|
"author": "wallpants",
|
|
5
5
|
"description": "Markdown to 'GitHub HTML' parser",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@happy-dom/global-registrator": "^12.10.3",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
47
|
-
"@typescript-eslint/parser": "^6.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
|
47
|
+
"@typescript-eslint/parser": "^6.16.0",
|
|
48
48
|
"bun-types": "latest",
|
|
49
49
|
"commitizen": "^4.3.0",
|
|
50
50
|
"cz-conventional-changelog": "^3.3.0",
|
|
51
|
-
"eslint": "^8.
|
|
52
|
-
"prettier": "^3.1.
|
|
51
|
+
"eslint": "^8.56.0",
|
|
52
|
+
"prettier": "^3.1.1",
|
|
53
53
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
54
|
-
"semantic-release": "^22.0.
|
|
55
|
-
"typescript": "5.
|
|
54
|
+
"semantic-release": "^22.0.12",
|
|
55
|
+
"typescript": "5.3.3"
|
|
56
56
|
}
|
|
57
57
|
}
|
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,
|