pantsdown 1.7.1 → 1.7.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 +18 -6
- package/package.json +1 -1
- package/src/rules/block.ts +1 -5
- package/src/tokenizer.ts +2 -2
- package/src/utils.ts +1 -0
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ some features developed specifically for [github-preview.nvim](https://github.co
|
|
|
11
11
|
If you need a feature that's supported by GitHub and is not already listed in the [Roadmap](#roadmap),
|
|
12
12
|
feel free to open an issue.
|
|
13
13
|
|
|
14
|
-
### [Demo](https://wallpants.github.io/pantsdown/)
|
|
14
|
+
### ▶️ [Demo](https://wallpants.github.io/pantsdown/)
|
|
15
15
|
|
|
16
|
-
## Installation
|
|
16
|
+
## 📦 Installation
|
|
17
17
|
|
|
18
18
|
🚨 Pantsdown is distributed only as a TypeScript module. This means you'll need a bundler to handle transpilation.
|
|
19
19
|
See below for usage examples.
|
|
@@ -25,7 +25,7 @@ bun install pantsdown
|
|
|
25
25
|
npm install pantsdown
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## Usage
|
|
28
|
+
## 💻 Usage
|
|
29
29
|
|
|
30
30
|
### Styles
|
|
31
31
|
|
|
@@ -79,7 +79,7 @@ function App() {
|
|
|
79
79
|
if (container) container.innerHTML = html;
|
|
80
80
|
}, []);
|
|
81
81
|
|
|
82
|
-
//
|
|
82
|
+
// ⚠️ for styles to be applied, a parent element must have
|
|
83
83
|
// the classes "pantsdown light" or "pantsdown dark" added
|
|
84
84
|
return <div id="markdown-container" className="pantsdown light" />;
|
|
85
85
|
}
|
|
@@ -87,7 +87,7 @@ function App() {
|
|
|
87
87
|
export default App;
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
## Configuration
|
|
90
|
+
## ⚙️ Configuration
|
|
91
91
|
|
|
92
92
|
The Pantsdown constructor accepts an optional configuration object:
|
|
93
93
|
|
|
@@ -129,6 +129,18 @@ const html = pantsdown.parse(markdown);
|
|
|
129
129
|
console.log(html);
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
##
|
|
132
|
+
## 🤝 Acknowledgements
|
|
133
133
|
|
|
134
|
+
<a href="https://marked.js.org">
|
|
135
|
+
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
|
|
136
|
+
</a>
|
|
137
|
+
|
|
138
|
+
Pantsdown is based on [Marked](https://github.com/markedjs/marked).
|
|
139
|
+
Without their hard work, Pantsdown would not exist.
|
|
140
|
+
|
|
141
|
+
## 🚀 Roadmap
|
|
142
|
+
|
|
143
|
+
- [ ] check if copy code button works with current vite docs
|
|
144
|
+
- [ ] showcase more in demo | list features
|
|
145
|
+
- [ ] [Alerts](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)
|
|
134
146
|
- [ ] [Mermaid](https://mermaid.js.org/) usage docs.
|
package/package.json
CHANGED
package/src/rules/block.ts
CHANGED
|
@@ -111,10 +111,6 @@ const block_blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
|
|
|
111
111
|
.replace("paragraph", block_paragraph)
|
|
112
112
|
.getRegex();
|
|
113
113
|
|
|
114
|
-
const block_footnote = edit(/^( {0,3}\[\^(\d+)\]:(?:[ \t]+|[\n]*?|$)?(paragraph|[^\n]*))+/)
|
|
115
|
-
.replace("paragraph", block_paragraph)
|
|
116
|
-
.getRegex();
|
|
117
|
-
|
|
118
114
|
export const block: Record<BlockRuleNames, RegExp> = {
|
|
119
115
|
newline: /^(?: *(?:\n|$))+/,
|
|
120
116
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
@@ -130,6 +126,6 @@ export const block: Record<BlockRuleNames, RegExp> = {
|
|
|
130
126
|
table: block_table,
|
|
131
127
|
lheading: block_lheading,
|
|
132
128
|
paragraph: block_paragraph,
|
|
133
|
-
footnote:
|
|
129
|
+
footnote: /^\[\^([^\]\n]+)\]:(?:[ \t]+|[\n]*?|$)([^\[\n]*?(?:\n|$)(?:[\n]*?[ ]{4,}[^\[\n]*)*)/,
|
|
134
130
|
text: /^[^\n]+/,
|
|
135
131
|
};
|
package/src/tokenizer.ts
CHANGED
|
@@ -330,8 +330,8 @@ export class Tokenizer {
|
|
|
330
330
|
const cap = block.footnote.exec(src);
|
|
331
331
|
if (!cap) return undefined;
|
|
332
332
|
|
|
333
|
-
const label = cap[
|
|
334
|
-
let text = cap[
|
|
333
|
+
const label = cap[1] ?? "";
|
|
334
|
+
let text = cap[2] ? rtrim(cap[2].replace(/^ *[ \t]?/gm, ""), "\n") : "";
|
|
335
335
|
|
|
336
336
|
text += `<a href="#footnote-ref-${encodeURIComponent(
|
|
337
337
|
label,
|