git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: ensure that `-M csquotes` works even in fragment mode.
9187b4bJohn MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+11−10
@@ -155,7 +155,8 @@ pandocToLaTeX options (Pandoc meta blocks) = do
155 _ -> "article"
155 _ -> "article"
156 when (documentClass `elem` chaptersClasses) $
156 when (documentClass `elem` chaptersClasses) $
157 modify $ \s -> s{ stHasChapters = True }
157 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
159 Nothing -> return ()
160 Nothing -> return ()
160 Just "false" -> return ()
161 Just "false" -> return ()
161 Just _ -> modify $ \s -> s{stCsquotes = True}
162 Just _ -> modify $ \s -> s{stCsquotes = True}
@@ -1423,14 +1424,14 @@ type Prefix = [Inline]
1423type Suffix = [Inline]
1424type Suffix = [Inline]
1424type CiteId = Text
1425type CiteId = Text
1425data CiteGroup = CiteGroup Prefix Suffix [CiteId]
1426data CiteGroup = CiteGroup Prefix Suffix [CiteId]
1426−
1427+
1427citeArgumentsList :: PandocMonad m
1428citeArgumentsList :: PandocMonad m
1428 => CiteGroup -> LW m (Doc Text)
1429 => CiteGroup -> LW m (Doc Text)
1429citeArgumentsList (CiteGroup _ _ []) = return empty
1430citeArgumentsList (CiteGroup _ _ []) = return empty
1430−citeArgumentsList (CiteGroup pfxs sfxs ids) = do
1431+citeArgumentsList (CiteGroup pfxs sfxs ids) = do
1431 pdoc <- inlineListToLaTeX pfxs
1432 pdoc <- inlineListToLaTeX pfxs
1432− sdoc <- inlineListToLaTeX sfxs'
1433+ sdoc <- inlineListToLaTeX sfxs'
1433− return $ (optargs pdoc sdoc) <>
1434+ return $ (optargs pdoc sdoc) <>
1434 (braces (literal (T.intercalate "," (reverse ids))))
1435 (braces (literal (T.intercalate "," (reverse ids))))
1435 where sfxs' = stripLocatorBraces $ case sfxs of
1436 where sfxs' = stripLocatorBraces $ case sfxs of
1436 (Str t : r) -> case T.uncons t of
1437 (Str t : r) -> case T.uncons t of
@@ -1479,22 +1480,22 @@ citationsToBiblatex (c:cs)
1479 NormalCitation -> "\\autocite"
1480 NormalCitation -> "\\autocite"
1480 return $ text cmd <>
1481 return $ text cmd <>
1481 braces (literal (T.intercalate "," (map citationId (c:cs))))
1482 braces (literal (T.intercalate "," (map citationId (c:cs))))
1482− | otherwise
1483+ | otherwise
1483− = do
1484+ = do
1484 let cmd = case citationMode c of
1485 let cmd = case citationMode c of
1485 SuppressAuthor -> "\\autocites*"
1486 SuppressAuthor -> "\\autocites*"
1486 AuthorInText -> "\\textcites"
1487 AuthorInText -> "\\textcites"
1487 NormalCitation -> "\\autocites"
1488 NormalCitation -> "\\autocites"
1488−
1489+
1489 groups <- mapM citeArgumentsList (reverse (foldl' grouper [] (c:cs)))
1490 groups <- mapM citeArgumentsList (reverse (foldl' grouper [] (c:cs)))
1490
1491
1491 return $ text cmd <> (mconcat groups)
1492 return $ text cmd <> (mconcat groups)
1492
1493
1493− where grouper prev cit = case prev of
1494+ where grouper prev cit = case prev of
1494 ((CiteGroup oPfx oSfx ids):rest)
1495 ((CiteGroup oPfx oSfx ids):rest)
1495 | null oSfx && null pfx -> (CiteGroup oPfx sfx (cid:ids)):rest
1496 | null oSfx && null pfx -> (CiteGroup oPfx sfx (cid:ids)):rest
1496 _ -> (CiteGroup pfx sfx [cid]):prev
1497 _ -> (CiteGroup pfx sfx [cid]):prev
1497− where pfx = citationPrefix cit
1498+ where pfx = citationPrefix cit
1498 sfx = citationSuffix cit
1499 sfx = citationSuffix cit
1499 cid = citationId cit
1500 cid = citationId cit
1500
1501
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+```