quikdown 1.0.2 → 1.0.3
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 +114 -17
- package/dist/quikdown-lex.cjs +810 -0
- package/dist/quikdown-lex.esm.js +808 -0
- package/dist/quikdown-lex.esm.min.js +8 -0
- package/dist/quikdown-lex.esm.min.js.map +1 -0
- package/dist/quikdown-lex.umd.js +816 -0
- package/dist/quikdown-lex.umd.min.js +8 -0
- package/dist/quikdown-lex.umd.min.js.map +1 -0
- package/dist/quikdown.cjs +164 -169
- package/dist/quikdown.d.ts +70 -0
- package/dist/quikdown.dark.css +115 -56
- package/dist/quikdown.dark.min.css +2 -0
- package/dist/quikdown.esm.js +164 -169
- package/dist/quikdown.esm.min.js +2 -2
- package/dist/quikdown.esm.min.js.map +1 -1
- package/dist/quikdown.light.css +84 -52
- package/dist/quikdown.light.min.css +2 -0
- package/dist/quikdown.umd.js +164 -169
- package/dist/quikdown.umd.min.js +2 -2
- package/dist/quikdown.umd.min.js.map +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# quikdown
|
|
2
2
|
|
|
3
3
|
[](https://github.com/deftio/quikdown/actions/workflows/ci.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/quikdown)
|
|
5
|
+
[](https://github.com/deftio/quikdown)
|
|
6
6
|
[](https://opensource.org/licenses/BSD-2-Clause)
|
|
7
|
-
[](https://github.com/deftio/quikdown/tree/main/dist)
|
|
8
8
|
|
|
9
9
|
A lightweight, fast markdown parser with built-in XSS protection. Quikdown works in both browser and Node.js environments. Via its fenced plug-in support it can support highlighted code blocks, diagrams, and other custom fenced content.
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ A lightweight, fast markdown parser with built-in XSS protection. Quikdown works
|
|
|
16
16
|
|
|
17
17
|
- 🚀 **Lightweight** - Under 10KB minified
|
|
18
18
|
- 🔒 **Secure by default** - Built-in XSS protection with URL sanitization
|
|
19
|
-
- 🎨 **Flexible styling** - Inline styles or CSS classes including
|
|
19
|
+
- 🎨 **Flexible styling** - Inline styles or CSS classes including light and dark mode generation, custom themes
|
|
20
20
|
- 🔌 **Plugin system** - Extensible fence block handlers
|
|
21
21
|
- 📦 **Zero dependencies** - No external libraries required
|
|
22
22
|
- 🌐 **Universal** - Works in browsers and Node.js
|
|
@@ -32,10 +32,28 @@ npm install quikdown
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
Or via CDN:
|
|
35
|
+
|
|
36
|
+
**ES Modules (recommended for modern applications):**
|
|
37
|
+
```html
|
|
38
|
+
<script type="module">
|
|
39
|
+
import quikdown from 'https://unpkg.com/quikdown/dist/quikdown.esm.min.js';
|
|
40
|
+
|
|
41
|
+
const html = quikdown('# Hello World');
|
|
42
|
+
document.body.innerHTML = html;
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**UMD (for legacy browser support):**
|
|
35
47
|
```html
|
|
36
|
-
<script src="https://unpkg.com/quikdown/dist/quikdown.umd.js"></script>
|
|
48
|
+
<script src="https://unpkg.com/quikdown/dist/quikdown.umd.min.js"></script>
|
|
49
|
+
<script>
|
|
50
|
+
// Available as window.quikdown
|
|
51
|
+
const html = quikdown('# Hello World');
|
|
52
|
+
</script>
|
|
37
53
|
```
|
|
38
54
|
|
|
55
|
+
> **Production tip:** Pin to a specific version for stability (e.g., `https://unpkg.com/quikdown@1.0.3/dist/quikdown.esm.min.js`)
|
|
56
|
+
|
|
39
57
|
## Quick Start
|
|
40
58
|
|
|
41
59
|
### Basic Usage
|
|
@@ -58,6 +76,23 @@ const html = quikdown(markdown, {
|
|
|
58
76
|
});
|
|
59
77
|
```
|
|
60
78
|
|
|
79
|
+
### TypeScript Support
|
|
80
|
+
|
|
81
|
+
quikdown includes TypeScript definitions for better IDE support and type safety:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import quikdown, { QuikdownOptions } from 'quikdown';
|
|
85
|
+
|
|
86
|
+
const options: QuikdownOptions = {
|
|
87
|
+
inline_styles: true,
|
|
88
|
+
fence_plugin: (content: string, language: string) => {
|
|
89
|
+
return `<pre class="hljs ${language}">${content}</pre>`;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const html: string = quikdown(markdown, options);
|
|
94
|
+
```
|
|
95
|
+
|
|
61
96
|
## Supported Markdown
|
|
62
97
|
|
|
63
98
|
quikdown supports a practical subset of CommonMark:
|
|
@@ -229,6 +264,10 @@ const safe = quikdown(unsafe);
|
|
|
229
264
|
// Output: <script>alert("XSS")</script> <strong>bold</strong>
|
|
230
265
|
```
|
|
231
266
|
|
|
267
|
+
## Quikdown Lexer Version
|
|
268
|
+
An experimental lexer-based implementation is available for testing. See [docs/lexer-implementation.md](docs/lexer-implementation.md) for details.
|
|
269
|
+
|
|
270
|
+
|
|
232
271
|
## API Reference
|
|
233
272
|
|
|
234
273
|
For complete API documentation, see [docs/api-reference.md](docs/api-reference.md)
|
|
@@ -259,29 +298,77 @@ const myParser = quikdown.configure({
|
|
|
259
298
|
const html = myParser(markdown);
|
|
260
299
|
```
|
|
261
300
|
|
|
262
|
-
### `quikdown.emitStyles()`
|
|
301
|
+
### `quikdown.emitStyles(prefix?, theme?)`
|
|
263
302
|
|
|
264
303
|
Returns CSS styles for quikdown HTML output when not using inline styles.
|
|
265
304
|
|
|
305
|
+
**Parameters:**
|
|
306
|
+
- `prefix` (string, optional): CSS class prefix (default: 'quikdown-')
|
|
307
|
+
- `theme` (string, optional): Theme name - 'light' or 'dark' (default: 'light')
|
|
308
|
+
|
|
266
309
|
```javascript
|
|
267
|
-
|
|
310
|
+
// Get light theme CSS
|
|
311
|
+
const lightStyles = quikdown.emitStyles();
|
|
312
|
+
|
|
313
|
+
// Get dark theme CSS
|
|
314
|
+
const darkStyles = quikdown.emitStyles('quikdown-', 'dark');
|
|
315
|
+
|
|
268
316
|
// Add to your stylesheet or <style> tag
|
|
269
317
|
```
|
|
270
318
|
|
|
319
|
+
## Theming
|
|
320
|
+
|
|
321
|
+
QuikDown supports flexible theming through container-based CSS scoping:
|
|
322
|
+
|
|
323
|
+
### Using Pre-built Themes
|
|
324
|
+
|
|
325
|
+
```html
|
|
326
|
+
<!-- Load theme CSS files -->
|
|
327
|
+
<link rel="stylesheet" href="quikdown.light.css">
|
|
328
|
+
<link rel="stylesheet" href="quikdown.dark.css">
|
|
329
|
+
|
|
330
|
+
<!-- Apply themes via container classes -->
|
|
331
|
+
<div class="quikdown-light">
|
|
332
|
+
<!-- Light themed content -->
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div class="quikdown-dark">
|
|
336
|
+
<!-- Dark themed content -->
|
|
337
|
+
</div>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Theme Architecture
|
|
341
|
+
|
|
342
|
+
- **Structural styles**: Shared across all themes (margins, padding, font-sizes)
|
|
343
|
+
- **Theme colors**: Scoped to container classes (`.quikdown-light`, `.quikdown-dark`)
|
|
344
|
+
- **No conflicts**: Multiple themes can coexist on the same page
|
|
345
|
+
- **No default theme**: Without a container class, only structural styles apply
|
|
346
|
+
|
|
347
|
+
### Inline Styles
|
|
348
|
+
|
|
349
|
+
For a batteries-included approach without CSS files:
|
|
350
|
+
|
|
351
|
+
```javascript
|
|
352
|
+
// Use inline styles (always light theme currently)
|
|
353
|
+
const html = quikdown(markdown, { inline_styles: true });
|
|
354
|
+
```
|
|
355
|
+
|
|
271
356
|
## Browser Usage
|
|
272
357
|
|
|
273
|
-
###
|
|
358
|
+
### ES Modules (Recommended)
|
|
274
359
|
|
|
275
360
|
```html
|
|
276
361
|
<!DOCTYPE html>
|
|
277
362
|
<html>
|
|
278
363
|
<head>
|
|
279
|
-
<
|
|
364
|
+
<meta charset="UTF-8">
|
|
280
365
|
</head>
|
|
281
366
|
<body>
|
|
282
367
|
<div id="output"></div>
|
|
283
|
-
<script>
|
|
284
|
-
|
|
368
|
+
<script type="module">
|
|
369
|
+
import quikdown from 'https://unpkg.com/quikdown/dist/quikdown.esm.min.js';
|
|
370
|
+
|
|
371
|
+
const markdown = '# Hello quikdown!\n\nSupports **bold** and *italic* text.';
|
|
285
372
|
const html = quikdown(markdown, { inline_styles: true });
|
|
286
373
|
document.getElementById('output').innerHTML = html;
|
|
287
374
|
</script>
|
|
@@ -289,13 +376,23 @@ const styles = quikdown.emitStyles();
|
|
|
289
376
|
</html>
|
|
290
377
|
```
|
|
291
378
|
|
|
292
|
-
###
|
|
293
|
-
|
|
294
|
-
```javascript
|
|
295
|
-
import quikdown from 'quikdown';
|
|
379
|
+
### UMD Script Tag (Legacy)
|
|
296
380
|
|
|
297
|
-
|
|
298
|
-
|
|
381
|
+
```html
|
|
382
|
+
<!DOCTYPE html>
|
|
383
|
+
<html>
|
|
384
|
+
<head>
|
|
385
|
+
<script src="https://unpkg.com/quikdown/dist/quikdown.umd.min.js"></script>
|
|
386
|
+
</head>
|
|
387
|
+
<body>
|
|
388
|
+
<div id="output"></div>
|
|
389
|
+
<script>
|
|
390
|
+
const markdown = '# Hello quikdown!';
|
|
391
|
+
const html = quikdown(markdown, { inline_styles: true });
|
|
392
|
+
document.getElementById('output').innerHTML = html;
|
|
393
|
+
</script>
|
|
394
|
+
</body>
|
|
395
|
+
</html>
|
|
299
396
|
```
|
|
300
397
|
|
|
301
398
|
## Node.js Usage
|