Skip to content

Commit

Permalink
fix: code line highlighter extract new line
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 14, 2021
1 parent 29d564f commit 66898a8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/slidev/node/plugins/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function truncateMancoMark(code: string) {
export function transformHighlighter(md: string) {
return md.replace(/^```(\w+?)\s*{([\d\w*,\|-]+)}\s*({.*?})[\s\n]*([\s\S]+?)^```/mg, (full, lang = '', rangeStr: string, options = '', code: string) => {
const ranges = rangeStr.split(/\|/g).map(i => i.trim())
code = code.trimEnd()
options = options.trim() || '{}'
return `\n<CodeHighlightController v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>\n\n\`\`\`${lang}\n${code}\n\`\`\`\n\n</CodeHighlightController>`
})
Expand Down

0 comments on commit 66898a8

Please sign in to comment.