Skip to content

Commit

Permalink
Fix defaultShikiRenderer ignoring theme's fontStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Oct 21, 2024
1 parent 42015c1 commit a060c9a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/shiki-twoslash/src/renderers/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ export function defaultShikiRenderer(lines: Lines, options: HtmlRendererOptions,
html += prefix

l.forEach(token => {
html += `<span style="color: ${token.color}">${escapeHtml(token.content)}</span>`
const cssDeclarations = [`color: ${token.color}`];
if (token.fontStyle & shiki.FontStyle.Italic) {
cssDeclarations.push('font-style: italic');
}
if (token.fontStyle & shiki.FontStyle.Bold) {
cssDeclarations.push('font-weight: bold');
}
if (token.fontStyle & shiki.FontStyle.Underline) {
cssDeclarations.push('text-decoration: underline');
}
html += `<span style="color: ${cssDeclarations.join('; ')}">${escapeHtml(token.content)}</span>`
})
html += `</div>`
}
Expand Down

0 comments on commit a060c9a

Please sign in to comment.