aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-12-20 10:01:06 -0800
committerJohn MacFarlane <[email protected]>2024-12-20 10:01:06 -0800
commit74f64f33e47fa61172cc94c23a8811a6b4c6eeec (patch)
tree31b2042afb07a625178b6642643044d1f1f18801 /src
parent7b873ac79093d9bb4a31fd54939019a5a8c098f6 (diff)
LaTeX writer: properly handle boolean value for `csquotes` variable.
Closes #10403.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 5df392074..77d40c3e7 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -39,7 +39,7 @@ import Data.Monoid (Any (..))
import Data.Text (Text)
import qualified Data.Text as T
import Network.URI (unEscapeString)
-import Text.DocTemplates (FromContext(lookupContext), renderTemplate)
+import Text.DocTemplates (FromContext(lookupContext), Val(..), renderTemplate)
import Text.Collate.Lang (renderLang, Lang(langLanguage))
import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang)
import Text.Pandoc.Definition
@@ -157,11 +157,15 @@ pandocToLaTeX options (Pandoc meta blocks) = do
_ -> "article"
when (documentClass `elem` chaptersClasses) $
modify $ \s -> s{ stHasChapters = True }
- case lookupContext "csquotes" (writerVariables options) `mplus`
- (stringify <$> lookupMeta "csquotes" meta) of
- Nothing -> return ()
- Just "false" -> return ()
- Just _ -> modify $ \s -> s{stCsquotes = True}
+ let csquotes =
+ case lookupContext "csquotes" (writerVariables options) of
+ Just (BoolVal v) -> v
+ Just (SimpleVal (Text _ t)) -> t /= ("false" :: Text)
+ _ -> case stringify <$> lookupMeta "csquotes" meta of
+ Nothing -> False
+ Just "false" -> False
+ Just _ -> True
+ when csquotes $ modify $ \s -> s{stCsquotes = True}
let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
(blocks', [])
else case reverse blocks' of