Skip to content

Commit 66898a8

Browse files
committed
fix: code line highlighter extract new line
1 parent 29d564f commit 66898a8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/slidev/node/plugins/markdown.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export function truncateMancoMark(code: string) {
103103
export function transformHighlighter(md: string) {
104104
return md.replace(/^```(\w+?)\s*{([\d\w*,\|-]+)}\s*({.*?})[\s\n]*([\s\S]+?)^```/mg, (full, lang = '', rangeStr: string, options = '', code: string) => {
105105
const ranges = rangeStr.split(/\|/g).map(i => i.trim())
106+
code = code.trimEnd()
106107
options = options.trim() || '{}'
107108
return `\n<CodeHighlightController v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>\n\n\`\`\`${lang}\n${code}\n\`\`\`\n\n</CodeHighlightController>`
108109
})

0 commit comments

Comments
 (0)