Skip to content

Commit 443d158

Browse files
committed
fix: alert and todo-list
1 parent 4cc2c24 commit 443d158

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jian-doc",
33
"private": true,
4-
"version": "0.0.3",
4+
"version": "0.0.4",
55
"scripts": {
66
"dev": "vite --host",
77
"build": "tsc && vite build",

src/plugins/alert-plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tips from "../icons/tips.svg?raw"
66
import important from "../icons/important.svg?raw"
77
import warning from "../icons/warning.svg?raw"
88
import caution from "../icons/caution.svg?raw"
9+
import _md from "./common.ts"
910

1011
const RuleAlert: RuleBlock = (
1112
state: StateBlock,
@@ -130,7 +131,7 @@ export const AlertPlugin = (md: MarkdownIt) => {
130131
return (
131132
`<div class="alert ${info}">` +
132133
`<p class="title">${icon}${info}</p>` +
133-
`<p class="content">${content}</p>` +
134+
`<p class="content">${_md.renderInline(content)}</p>` +
134135
`</div>`
135136
)
136137
}

src/plugins/common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import MarkdownIt from "markdown-it"
2+
3+
const _md = new MarkdownIt({ html: true, linkify: true })
4+
export default _md

src/plugins/todo-plugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import MarkdownIt, { Token } from "markdown-it"
2+
import _md from "./common.ts"
23

34
function isTodo(tokens: Token[], index: number): boolean {
45
return (
@@ -30,5 +31,7 @@ export const TodoPlugin = (md: MarkdownIt) => {
3031
}
3132
})
3233

33-
md.renderer.rules.todo = md.renderer.rules.text!.bind(md.renderer.rules)
34+
md.renderer.rules.todo = (tokens: Token[], index: number) => {
35+
return _md.renderInline(tokens[index].content)
36+
}
3437
}

0 commit comments

Comments
 (0)