MCPcopy Index your code
hub / github.com/banga/git-split-diffs / parseShikiColor

Function parseShikiColor

src/highlightSyntaxInLine.ts:7–31  ·  view source on GitHub ↗
(token: shiki.ThemedToken)

Source from the content-addressed store, hash-verified

5export type HighlightedText = [string, ThemeColor | null];
6
7function parseShikiColor(token: shiki.ThemedToken): ThemeColor {
8 let modifiers: ColorModifier[] | undefined;
9 if (
10 token.fontStyle !== undefined &&
11 token.fontStyle !== shiki.FontStyle.NotSet &&
12 token.fontStyle !== shiki.FontStyle.None
13 ) {
14 modifiers = [];
15 if (token.fontStyle & shiki.FontStyle.Bold) {
16 modifiers.push('bold');
17 }
18 if (token.fontStyle & shiki.FontStyle.Italic) {
19 modifiers.push('italic');
20 }
21 if (token.fontStyle & shiki.FontStyle.Underline) {
22 modifiers.push('underline');
23 }
24 }
25 const themeColor = parseColorDefinition({
26 color: token.color,
27 backgroundColor: token.bgColor,
28 modifiers,
29 });
30 return themeColor;
31}
32
33export async function highlightSyntaxInLine(
34 line: FormattedString,

Callers 1

highlightSyntaxInLineFunction · 0.85

Calls 1

parseColorDefinitionFunction · 0.90

Tested by

no test coverage detected