summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-01-09 12:16:24 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2016-01-09 12:16:24 -0800
commit1506e62f48af931e389b812b82b63c2f6d0d12b9 (patch)
tree261a03fde6e2cf3ff9f072769d4dbf9862b2d6ed
parent729911ad74254742251669f27cc432751644d238 (diff)
LaTeX writer: restore old treatment of Span.
A Span is rendered with surrounding {braces}. This was a regression in 1.16. Closes #2624.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs32
-rw-r--r--tests/writers-lang-and-dir.latex2
2 files changed, 16 insertions, 18 deletions
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) =
diff --git a/tests/writers-lang-and-dir.latex b/tests/writers-lang-and-dir.latex
index 2f1ee4fbe..056809a5e 100644
--- a/tests/writers-lang-and-dir.latex
+++ b/tests/writers-lang-and-dir.latex
@@ -89,7 +89,7 @@ div contents
and more text.
-Next paragraph with a span and a word-thatincludesaspanright?
+Next paragraph with a {span} and a word-thatincludesa{span}right?
\section{Directionality}\label{directionality}