From 4ee49e803d6e1f31825d7c6bfa03cb81cd055f08 Mon Sep 17 00:00:00 2001 From: Hannes Hauswedell Date: Thu, 23 Apr 2020 18:50:19 +0200 Subject: [PATCH] WIP --- src/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index d0b5c6c..da556a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ export function renderToLaTeX( const renderedLines = lines .map((line) => line - .map(({ content, color }) => { + .map(({ content, color, preserveFontStyle, fontStyle }) => { const normalizedColor = Color(color ?? defaultColor) .hex() .slice(1); @@ -42,7 +42,15 @@ export function renderToLaTeX( .join(""); }) .join("$"); - return `\\textcolor[HTML]{${normalizedColor}}{${escapedContent}}`; + var fontStyleStr:string = ""; + var fontStyleStr2:string = ""; + if (preserveFontStyle && fontStyle == `font-weight: bold`) + fontStyleStr2 += `\\bfseries`; + if (preserveFontStyle && fontStyle == `font-style: italic;`) + fontStyleStr2 += `\\itshape`; + if (preserveFontStyle && fontStyle == `text-decoration: underline`) + fontStyleStr = `\\underline`; + return `${fontStyleStr}{${fontStyleStr2}\\textcolor[HTML]{${normalizedColor}}{${escapedContent}}}`; }) .join("") )