diff --git a/src/Text/TeXMath/Writers/Typst.hs b/src/Text/TeXMath/Writers/Typst.hs index b7cf9f5e..b24ff99f 100644 --- a/src/Text/TeXMath/Writers/Typst.hs +++ b/src/Text/TeXMath/Writers/Typst.hs @@ -84,13 +84,14 @@ esc t = escInQuotes :: Text -> Text escInQuotes t = - if T.any (== '"') t + if T.any needsEscape t then T.concatMap escapeChar t else t where escapeChar c - | c == '"' = "\\" <> T.singleton c + | needsEscape c = "\\" <> T.singleton c | otherwise = T.singleton c + needsEscape c = c == '\\' || c == '"' writeExpS :: Exp -> Text writeExpS (EGrouped es) = "(" <> writeExps es <> ")" diff --git a/test/regression/245a.test b/test/regression/245a.test new file mode 100644 index 00000000..0fda51a1 --- /dev/null +++ b/test/regression/245a.test @@ -0,0 +1,4 @@ +<<< native +[ EText TextNormal "\\tau" ] +>>> typst +upright("\\tau")