Skip to content

Commit

Permalink
fix: don't render a empty line
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1030 committed Apr 17, 2024
1 parent 41acaf7 commit 58d062f
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,7 @@ export function useHighlight(input: Ref<string | undefined>, props: Ref<Resolved

function highlighting(highlighter: HighlighterCore) {
loadingToHTML.value = true
output.value = highlighter.codeToHtml(input.value ?? '', {
...props.value.codeToHastOptions,
transformers: [
...props.value.codeToHastOptions.transformers ?? [],
{
preprocess(code) {
// Workaround for https://github.com/shikijs/shiki/issues/608
// When last span is empty, it's height is 0px
// so add a newline to render it correctly
if (code.endsWith('\n'))
return `${code}\n`
},
},
],
})
output.value = highlighter.codeToHtml(input.value ?? '', props.value.codeToHastOptions)
loadingToHTML.value = false
}

Expand Down

0 comments on commit 58d062f

Please sign in to comment.