diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-04-11 10:40:59 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-04-11 10:40:59 -0700 |
commit | 9187b4bca9fc42ad7ca865d1e691664a463c8924 (patch) | |
tree | e20f1c8d713caf6322249788306b2bcc9ec27480 | |
parent | dd06d6354081f478e99d864ac4343896ec887eda (diff) | |
download | pandoc-9187b4bca9fc42ad7ca865d1e691664a463c8924.tar.gz |
LaTeX writer: ensure that `-M csquotes` works even in fragment mode.
Closes #6265.
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 21 | ||||
-rw-r--r-- | test/command/6265.md | 6 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 37fa72c27..1670f8380 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -155,7 +155,8 @@ pandocToLaTeX options (Pandoc meta blocks) = do _ -> "article" when (documentClass `elem` chaptersClasses) $ modify $ \s -> s{ stHasChapters = True } - case T.toLower . render Nothing <$> getField "csquotes" metadata of + case lookupContext "csquotes" (writerVariables options) `mplus` + (stringify <$> lookupMeta "csquotes" meta) of Nothing -> return () Just "false" -> return () Just _ -> modify $ \s -> s{stCsquotes = True} @@ -1423,14 +1424,14 @@ type Prefix = [Inline] type Suffix = [Inline] type CiteId = Text data CiteGroup = CiteGroup Prefix Suffix [CiteId] - + citeArgumentsList :: PandocMonad m => CiteGroup -> LW m (Doc Text) citeArgumentsList (CiteGroup _ _ []) = return empty -citeArgumentsList (CiteGroup pfxs sfxs ids) = do +citeArgumentsList (CiteGroup pfxs sfxs ids) = do pdoc <- inlineListToLaTeX pfxs - sdoc <- inlineListToLaTeX sfxs' - return $ (optargs pdoc sdoc) <> + sdoc <- inlineListToLaTeX sfxs' + return $ (optargs pdoc sdoc) <> (braces (literal (T.intercalate "," (reverse ids)))) where sfxs' = stripLocatorBraces $ case sfxs of (Str t : r) -> case T.uncons t of @@ -1479,22 +1480,22 @@ citationsToBiblatex (c:cs) NormalCitation -> "\\autocite" return $ text cmd <> braces (literal (T.intercalate "," (map citationId (c:cs)))) - | otherwise - = do + | otherwise + = do let cmd = case citationMode c of SuppressAuthor -> "\\autocites*" AuthorInText -> "\\textcites" NormalCitation -> "\\autocites" - + groups <- mapM citeArgumentsList (reverse (foldl' grouper [] (c:cs))) return $ text cmd <> (mconcat groups) - where grouper prev cit = case prev of + where grouper prev cit = case prev of ((CiteGroup oPfx oSfx ids):rest) | null oSfx && null pfx -> (CiteGroup oPfx sfx (cid:ids)):rest _ -> (CiteGroup pfx sfx [cid]):prev - where pfx = citationPrefix cit + where pfx = citationPrefix cit sfx = citationSuffix cit cid = citationId cit diff --git a/test/command/6265.md b/test/command/6265.md new file mode 100644 index 000000000..7b2ada37e --- /dev/null +++ b/test/command/6265.md @@ -0,0 +1,6 @@ +``` +% pandoc -f markdown -t latex -M csquotes=true +"test" +^D +\enquote{test} +``` |