git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: ensure that `-M csquotes` works even in fragment mode.

Closes #6265.

commit9187b4bca9fc42ad7ca865d1e691664a463c8924 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 11 Apr 2020, 10:40 (7 years ago) parentdd06d63
2 files changed+17−10
src/Text/Pandoc/Writers/LaTeX.hs+11−10 test/command/6265.md+6
src/Text/Pandoc/Writers/LaTeX.hs+11−10
@@ -155,7 +155,8 @@ pandocToLaTeX options (Pandoc meta blocks) = do
155155 _ -> "article"
156156 when (documentClass `elem` chaptersClasses) $
157157 modify $ \s -> s{ stHasChapters = True }
158− case T.toLower . render Nothing <$> getField "csquotes" metadata of
158+ case lookupContext "csquotes" (writerVariables options) `mplus`
159+ (stringify <$> lookupMeta "csquotes" meta) of
159160 Nothing -> return ()
160161 Just "false" -> return ()
161162 Just _ -> modify $ \s -> s{stCsquotes = True}
@@ -1423,14 +1424,14 @@ type Prefix = [Inline]
14231424type Suffix = [Inline]
14241425type CiteId = Text
14251426data CiteGroup = CiteGroup Prefix Suffix [CiteId]
1426−
1427+
14271428citeArgumentsList :: PandocMonad m
14281429 => CiteGroup -> LW m (Doc Text)
14291430citeArgumentsList (CiteGroup _ _ []) = return empty
1430−citeArgumentsList (CiteGroup pfxs sfxs ids) = do
1431+citeArgumentsList (CiteGroup pfxs sfxs ids) = do
14311432 pdoc <- inlineListToLaTeX pfxs
1432− sdoc <- inlineListToLaTeX sfxs'
1433− return $ (optargs pdoc sdoc) <>
1433+ sdoc <- inlineListToLaTeX sfxs'
1434+ return $ (optargs pdoc sdoc) <>
14341435 (braces (literal (T.intercalate "," (reverse ids))))
14351436 where sfxs' = stripLocatorBraces $ case sfxs of
14361437 (Str t : r) -> case T.uncons t of
@@ -1479,22 +1480,22 @@ citationsToBiblatex (c:cs)
14791480 NormalCitation -> "\\autocite"
14801481 return $ text cmd <>
14811482 braces (literal (T.intercalate "," (map citationId (c:cs))))
1482− | otherwise
1483− = do
1483+ | otherwise
1484+ = do
14841485 let cmd = case citationMode c of
14851486 SuppressAuthor -> "\\autocites*"
14861487 AuthorInText -> "\\textcites"
14871488 NormalCitation -> "\\autocites"
1488−
1489+
14891490 groups <- mapM citeArgumentsList (reverse (foldl' grouper [] (c:cs)))
14901491
14911492 return $ text cmd <> (mconcat groups)
14921493
1493− where grouper prev cit = case prev of
1494+ where grouper prev cit = case prev of
14941495 ((CiteGroup oPfx oSfx ids):rest)
14951496 | null oSfx && null pfx -> (CiteGroup oPfx sfx (cid:ids)):rest
14961497 _ -> (CiteGroup pfx sfx [cid]):prev
1497− where pfx = citationPrefix cit
1498+ where pfx = citationPrefix cit
14981499 sfx = citationSuffix cit
14991500 cid = citationId cit
15001501
test/command/6265.mdnew file+6
@@ -0,0 +1,6 @@
1+```
2+% pandoc -f markdown -t latex -M csquotes=true
3+"test"
4+^D
5+\enquote{test}
6+```