From 1506e62f48af931e389b812b82b63c2f6d0d12b9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 9 Jan 2016 12:16:24 -0800 Subject: LaTeX writer: restore old treatment of Span. A Span is rendered with surrounding {braces}. This was a regression in 1.16. Closes #2624. --- src/Text/Pandoc/Writers/LaTeX.hs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 025915c37..2dcbf62bf 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -810,28 +810,26 @@ isQuoted _ = False inlineToLaTeX :: Inline -- ^ Inline to convert -> State WriterState Doc inlineToLaTeX (Span (id',classes,kvs) ils) = do - let noEmph = "csl-no-emph" `elem` classes - let noStrong = "csl-no-strong" `elem` classes - let noSmallCaps = "csl-no-smallcaps" `elem` classes - let rtl = ("dir","rtl") `elem` kvs - let ltr = ("dir","ltr") `elem` kvs ref <- toLabel id' let linkAnchor = if null id' then empty else "\\protect\\hypertarget" <> braces (text ref) <> braces empty - fmap (linkAnchor <>) - ((if noEmph then inCmd "textup" else id) . - (if noStrong then inCmd "textnormal" else id) . - (if noSmallCaps then inCmd "textnormal" else id) . - (if rtl then inCmd "RL" else id) . - (if ltr then inCmd "LR" else id) . - (case lookup "lang" kvs of - Just lng -> let (l, o) = toPolyglossia $ splitBy (=='-') lng - ops = if null o then "" else brackets (text o) - in \c -> char '\\' <> "text" <> text l <> ops <> braces c - Nothing -> id) - ) `fmap` inlineListToLaTeX ils + let cmds = ["textup" | "csl-no-emph" `elem` classes] ++ + ["textnormal" | "csl-no-strong" `elem` classes || + "csl-no-smallcaps" `elem` classes] ++ + ["RL" | ("dir", "rtl") `elem` kvs] ++ + ["LR" | ("dir", "ltr") `elem` kvs] ++ + (case lookup "lang" kvs of + Just lng -> let (l, o) = toPolyglossia $ splitBy (=='-') lng + ops = if null o then "" else ("[" ++ o ++ "]") + in ["text" ++ l ++ ops] + Nothing -> []) + contents <- inlineListToLaTeX ils + return $ linkAnchor <> + if null cmds + then braces contents + else foldr inCmd contents cmds inlineToLaTeX (Emph lst) = inlineListToLaTeX lst >>= return . inCmd "emph" inlineToLaTeX (Strong lst) = -- cgit v1.2.3