fix: fix line higlighting for empty lines

pull/2070/head
Evan You 2 years ago
parent 6ce88da3ba
commit 9708510cbd

@ -136,11 +136,17 @@ export async function highlight(
return s return s
} }
const fillEmptyHighlightedLine = (s: string) => {
return s.replace(
/(<span class="line highlighted">)(<\/span>)/g,
'$1<wbr>$2'
)
}
str = removeMustache(str) str = removeMustache(str)
const codeToHtml = (theme: IThemeRegistration) => { const codeToHtml = (theme: IThemeRegistration) => {
return cleanup( const res =
restoreMustache(
lang === 'ansi' lang === 'ansi'
? highlighter.ansiToHtml(str, { ? highlighter.ansiToHtml(str, {
lineOptions, lineOptions,
@ -151,8 +157,7 @@ export async function highlight(
lineOptions, lineOptions,
theme: getThemeName(theme) theme: getThemeName(theme)
}) })
) return fillEmptyHighlightedLine(cleanup(restoreMustache(res)))
)
} }
if (hasSingleTheme) return codeToHtml(theme) if (hasSingleTheme) return codeToHtml(theme)

Loading…
Cancel
Save