@lowlighter/markdown 1.0.0 → 1.2.0
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 +51 -6
- package/deno.jsonc +12 -7
- package/deno.lock +40 -424
- package/mod.mjs +1 -1
- package/package.json +6 -3
- package/plugins/math.mjs +1 -0
- package/plugins/mermaid.mjs +1 -0
- package/plugins/mod.mjs +1 -0
- package/plugins/mod.ts +14 -0
- package/renderer.mjs +1 -1
- package/renderer.ts +19 -5
- package/renderer_test.ts +5 -0
package/README.md
CHANGED
|
@@ -6,18 +6,63 @@
|
|
|
6
6
|
- [`🦕 Playground`](https://libs.lecoq.io/markdown)
|
|
7
7
|
- [`📚 Documentation`](https://jsr.io/@libs/markdown/doc)
|
|
8
8
|
|
|
9
|
+
## 📑 Examples
|
|
10
|
+
|
|
11
|
+
### Rendering markdown
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// Render markdown using the default renderer
|
|
15
|
+
import { Renderer } from "./renderer.ts"
|
|
16
|
+
await Renderer.render("# Hello, world!")
|
|
17
|
+
|
|
18
|
+
// Render markdown using a custom renderer
|
|
19
|
+
import { gfm, highlighting, markers, math, sanitize, wikilinks } from "./plugins/mod.ts"
|
|
20
|
+
const renderer = new Renderer({ plugins: [gfm, highlighting, math, markers, wikilinks, sanitize] })
|
|
21
|
+
await renderer.render("# Hello, world!")
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Creating a custom renderer with different plugins sources
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { Renderer } from "./renderer.ts"
|
|
28
|
+
import frontmatter from "./plugins/frontmatter.ts"
|
|
29
|
+
|
|
30
|
+
const renderer = await Renderer.with({
|
|
31
|
+
plugins: [
|
|
32
|
+
// You can specify an existing Plugin object...
|
|
33
|
+
frontmatter,
|
|
34
|
+
// ...or a a HTTPS import that points towards a compatible Plugin object!
|
|
35
|
+
"https://esm.sh/jsr/@libs/markdown/plugins/gfm",
|
|
36
|
+
],
|
|
37
|
+
})
|
|
38
|
+
await renderer.render("# foo")
|
|
39
|
+
```
|
|
40
|
+
|
|
9
41
|
## ✨ Features
|
|
10
42
|
|
|
11
43
|
- Render markdown to HTML using the [unified ecosystem](https://unifiedjs.com).
|
|
12
44
|
- Straightforward API for both basic markdown and extended markdown rendering
|
|
13
45
|
- Support out-of-the-box dozen of plugins to add extended markdown features
|
|
14
|
-
- Headings anchors
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
46
|
+
- [Headings anchors](https://jsr.io/@libs/markdown/doc/plugins/anchors/~/default)
|
|
47
|
+
- [Custom directives](https://jsr.io/@libs/markdown/doc/plugins/directives/~/default)
|
|
48
|
+
- [Emoji rendering](https://jsr.io/@libs/markdown/doc/plugins/emojis/~/default)
|
|
49
|
+
- [Frontmatter parsing](https://jsr.io/@libs/markdown/doc/plugins/frontmatter/~/default)
|
|
50
|
+
- [GitHub Flavored Markdown](https://jsr.io/@libs/markdown/doc/plugins/gfm/~/default)
|
|
51
|
+
- [Code highlighting](https://jsr.io/@libs/markdown/doc/plugins/highlighting/~/default)
|
|
52
|
+
- [Linebreaks](https://jsr.io/@libs/markdown/doc/plugins/linebreaks/~/default)
|
|
53
|
+
- [Markers](https://jsr.io/@libs/markdown/doc/plugins/markers/~/default)
|
|
54
|
+
- [Math rendering](https://jsr.io/@libs/markdown/doc/plugins/math/~/default)
|
|
55
|
+
- [Mermaid diagrams](https://jsr.io/@libs/markdown/doc/plugins/mermaid/~/default)
|
|
56
|
+
- [Ruby annotations](https://jsr.io/@libs/markdown/doc/plugins/ruby/~/default)
|
|
57
|
+
- [HTML sanitization](https://jsr.io/@libs/markdown/doc/plugins/sanitize/~/default)
|
|
58
|
+
- [Comment removal](https://jsr.io/@libs/markdown/doc/plugins/uncomments/~/default)
|
|
59
|
+
- [Wiki links](https://jsr.io/@libs/markdown/doc/plugins/wikilinks/~/default)
|
|
20
60
|
- etc.
|
|
61
|
+
- Plugins can be imported:
|
|
62
|
+
- From already existing Plugin objects
|
|
63
|
+
- From local sources
|
|
64
|
+
- From remote HTTPS sources
|
|
65
|
+
- The last option is particularly useful for user-provided customizations in a dynamic environment.
|
|
21
66
|
|
|
22
67
|
## 📜 Licenses and credits
|
|
23
68
|
|
package/deno.jsonc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"icon": "🖨️",
|
|
3
3
|
"name": "@libs/markdown",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "Markdown renderer with optional plugins based on the unified ecosystem.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -28,17 +28,20 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": "./mod.ts",
|
|
30
30
|
"./renderer": "./renderer.ts",
|
|
31
|
+
"./plugins": "./plugins/mod.ts",
|
|
31
32
|
"./plugins/anchors": "./plugins/anchors.ts",
|
|
32
|
-
"./plugins/highlighting": "./plugins/highlighting.ts",
|
|
33
33
|
"./plugins/directives": "./plugins/directives.ts",
|
|
34
34
|
"./plugins/emojis": "./plugins/emojis.ts",
|
|
35
35
|
"./plugins/frontmatter": "./plugins/frontmatter.ts",
|
|
36
36
|
"./plugins/gfm": "./plugins/gfm.ts",
|
|
37
|
+
"./plugins/highlighting": "./plugins/highlighting.ts",
|
|
37
38
|
"./plugins/linebreaks": "./plugins/linebreaks.ts",
|
|
38
39
|
"./plugins/markers": "./plugins/markers.ts",
|
|
39
|
-
"./plugins/
|
|
40
|
+
"./plugins/math": "./plugins/math.ts",
|
|
41
|
+
"./plugins/mermaid": "./plugins/mermaid.ts",
|
|
40
42
|
"./plugins/ruby": "./plugins/ruby.ts",
|
|
41
43
|
"./plugins/sanitize": "./plugins/sanitize.ts",
|
|
44
|
+
"./plugins/uncomments": "./plugins/uncomments.ts",
|
|
42
45
|
"./plugins/wikilinks": "./plugins/wikilinks.ts"
|
|
43
46
|
},
|
|
44
47
|
"imports": {
|
|
@@ -81,12 +84,14 @@
|
|
|
81
84
|
"tasks": {
|
|
82
85
|
"build": "npx playwright-core install --with-deps chromium",
|
|
83
86
|
"test": "deno test --allow-read --allow-env --allow-write --allow-sys --allow-run --no-prompt --coverage --clean --trace-leaks --doc",
|
|
84
|
-
"test:deno": "deno fmt --check && deno task test --filter='/^\\[deno\\]/' --quiet && deno coverage --exclude=.js && deno lint",
|
|
85
|
-
"test:deno-future": "DENO_FUTURE=1 && deno task test:deno",
|
|
86
|
-
"test:others": "deno fmt --check && deno task test --filter='/^\\[node|bun \\]/' --quiet && deno coverage --exclude=.js && deno lint",
|
|
87
|
+
"test:deno": "deno task clean:deno && deno fmt --check && deno task test --filter='/^\\[deno\\]/' --quiet && deno coverage --exclude=.js && deno lint",
|
|
88
|
+
"test:deno-future": "deno task clean:deno && DENO_FUTURE=1 && deno task test:deno",
|
|
89
|
+
"test:others": "deno task clean:others && deno fmt --check && deno task test --filter='/^\\[node|bun \\]/' --quiet && deno coverage --exclude=.js && deno lint",
|
|
87
90
|
"coverage:html": "deno task test --filter='/^\\[deno\\]/' --quiet && deno coverage --exclude=.js --html && sleep 1",
|
|
88
91
|
"dev": "deno fmt && deno task test --filter='/^\\[deno\\]/' && deno coverage --exclude=.js --detailed && deno task lint",
|
|
89
|
-
"lint": "deno fmt --check && deno lint && deno doc --lint mod.ts && deno publish --dry-run --quiet --allow-dirty"
|
|
92
|
+
"lint": "deno fmt --check && deno lint && deno doc --lint mod.ts && deno publish --dry-run --quiet --allow-dirty",
|
|
93
|
+
"clean:deno": "rm -rf node_modules .npmrc deno.lock",
|
|
94
|
+
"clean:others": "rm -rf node_modules .npmrc deno.lock package.json package-lock.json bun.lockb"
|
|
90
95
|
},
|
|
91
96
|
"lint": {
|
|
92
97
|
"rules": {
|