pantsdown 1.5.0 → 1.5.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/README.md +3 -3
- package/bunfig.toml +2 -0
- package/package.json +2 -1
- package/src/rules/block.ts +2 -2
- package/src/tokenizer.ts +4 -4
- package/src/sample.test.ts +0 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- Up to marked@9.1.
|
|
1
|
+
<!-- Up to marked@9.1.3 -->
|
|
2
2
|
|
|
3
3
|
# Pantsdown
|
|
4
4
|
|
|
@@ -73,7 +73,7 @@ const pantsdown = new Pantsdown();
|
|
|
73
73
|
|
|
74
74
|
function App() {
|
|
75
75
|
useEffect(() => {
|
|
76
|
-
const markdown = "# Hello world
|
|
76
|
+
const markdown = "# Hello world";
|
|
77
77
|
const html = pantsdown.parse(markdown);
|
|
78
78
|
const container = document.getElementById("markdown-container");
|
|
79
79
|
if (container) container.innerHTML = html;
|
|
@@ -114,7 +114,7 @@ const config: PantsdownConfig = {
|
|
|
114
114
|
relativeImageUrlPrefix: "/__localimage__/",
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
* Whether to render <details> html tags with attribute
|
|
117
|
+
* Whether to render <details> html tags with attribute open=""
|
|
118
118
|
*
|
|
119
119
|
* @default
|
|
120
120
|
* false
|
package/bunfig.toml
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantsdown",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"author": "wallpants",
|
|
5
5
|
"description": "Markdown to 'GitHub HTML' parser",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"highlight.js": "^11.9.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@happy-dom/global-registrator": "^12.10.3",
|
|
45
46
|
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
|
46
47
|
"@typescript-eslint/parser": "^6.7.3",
|
|
47
48
|
"bun-types": "latest",
|
package/src/rules/block.ts
CHANGED
|
@@ -83,7 +83,7 @@ const block_table = edit(
|
|
|
83
83
|
"(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)", // Cells
|
|
84
84
|
)
|
|
85
85
|
.replace("hr", block_hr)
|
|
86
|
-
.replace("heading", " {0,3}#{1,6}
|
|
86
|
+
.replace("heading", " {0,3}#{1,6}(?:\\s|$)")
|
|
87
87
|
.replace("blockquote", " {0,3}>")
|
|
88
88
|
.replace("code", " {4}[^\\n]")
|
|
89
89
|
.replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n")
|
|
@@ -96,7 +96,7 @@ const block_paragraph = edit(
|
|
|
96
96
|
/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
97
97
|
)
|
|
98
98
|
.replace("hr", block_hr)
|
|
99
|
-
.replace("heading", " {0,3}#{1,6}
|
|
99
|
+
.replace("heading", " {0,3}#{1,6}(?:\\s|$)")
|
|
100
100
|
.replace("|lheading", "") // setex headings don't interrupt commonmark paragraphs
|
|
101
101
|
.replace("table", block_table) // interrupt paragraphs with table
|
|
102
102
|
.replace("blockquote", " {0,3}>")
|
package/src/tokenizer.ts
CHANGED
|
@@ -369,16 +369,16 @@ export class Tokenizer {
|
|
|
369
369
|
* and update their sourceMap once they're closed.
|
|
370
370
|
*/
|
|
371
371
|
|
|
372
|
-
const capEndsWith = (str
|
|
372
|
+
const capEndsWith = (str?: string) => str && cap[0].trimEnd().endsWith(str);
|
|
373
373
|
|
|
374
374
|
const tag = inline.tag.exec(src);
|
|
375
|
-
const isHtmlClosed = capEndsWith(tag
|
|
375
|
+
const isHtmlClosed = capEndsWith(tag?.[0].slice(1));
|
|
376
376
|
|
|
377
|
-
if (!isHtmlClosed) {
|
|
377
|
+
if (tag?.[0] && !isHtmlClosed) {
|
|
378
378
|
// index where the token we just created will be inserted
|
|
379
379
|
const tokenIdx = this.lexer.tokens.length;
|
|
380
380
|
// first in last out
|
|
381
|
-
this.pendingHtmlClose.unshift([tag
|
|
381
|
+
this.pendingHtmlClose.unshift([tag[0], tokenIdx]);
|
|
382
382
|
} else if (this.pendingHtmlClose.length) {
|
|
383
383
|
for (const [pendingTag, index] of this.pendingHtmlClose) {
|
|
384
384
|
if (capEndsWith(pendingTag.slice(1))) {
|