Skip to content

Commit d0db092

Browse files
committed
fix: update the placeholder to still render the unhighlighted code
1 parent c828244 commit d0db092

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export interface MarkdownItAsyncOptions extends Omit<Options, 'highlight'> {
3131

3232
export type { MarkdownItAsyncOptions as Options }
3333

34-
const placeholder = (id: string): string => `<pre>::markdown-it-async::${id}::</pre>`
35-
const placeholderRe = /<pre>::markdown-it-async::(\w+)::<\/pre>/g
34+
const placeholder = (id: string, code: string): string => `<pre><!--::markdown-it-async::${id}::--><code>${code}</code></pre>`
35+
const placeholderRe = /<pre><!--::markdown-it-async::(\w+)::--><code>[\s\S]*?<\/code><\/pre>/g
3636

3737
function randStr(): string {
3838
return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)
@@ -141,7 +141,7 @@ function wrapHightlight(highlight: MarkdownItAsyncOptions['highlight'], map: Mar
141141
return promise
142142
const id = randStr()
143143
map.set(id, [promise, str, lang, attrs])
144-
return placeholder(id)
144+
return placeholder(id, str)
145145
}
146146

147147
wrappedSet.add(wrapped)

0 commit comments

Comments
 (0)