aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorTG <tarik.graba@telecom-paristech.fr>2019-02-07 19:01:58 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2019-02-09 08:21:53 -0800
commit8c2e2435f9f9d4ae92ec28a017d26e1c4a834393 (patch)
tree6171e277d4e47c1d638b2b83086dcd828c3324ad /src/Text/Pandoc
parent568b25d33a277b02cddbe646f3d6ec31f00ec99b (diff)
downloadpandoc-8c2e2435f9f9d4ae92ec28a017d26e1c4a834393.tar.gz
Asciidoctor writer sets the stem attribute if it contains latexmath
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
index a33fd8916..c67178b7a 100644
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -62,6 +62,7 @@ data WriterState = WriterState { defListMarker :: String
, intraword :: Bool
, autoIds :: Set.Set String
, asciidoctorVariant :: Bool
+ , hasMath :: Bool
}
defaultWriterState :: WriterState
@@ -71,6 +72,7 @@ defaultWriterState = WriterState { defListMarker = "::"
, intraword = False
, autoIds = Set.empty
, asciidoctorVariant = False
+ , hasMath = False
}
-- | Convert Pandoc to AsciiDoc.
@@ -101,11 +103,13 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
meta
body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
let main = render colwidth body
+ st <- get
let context = defField "body" main
$ defField "toc"
(writerTableOfContents opts &&
isJust (writerTemplate opts))
- $defField "titleblock" titleblock metadata
+ $ defField "math" (hasMath st)
+ $ defField "titleblock" titleblock metadata
case writerTemplate opts of
Nothing -> return main
Just tpl -> renderTemplate' tpl context
@@ -422,12 +426,14 @@ inlineToAsciiDoc _ (Code _ str) = return $
inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
inlineToAsciiDoc _ (Math InlineMath str) = do
isAsciidoctor <- gets asciidoctorVariant
+ modify $ \st -> st{ hasMath = True }
let content = if isAsciidoctor
then text str
else "$" <> text str <> "$"
return $ "latexmath:[" <> content <> "]"
inlineToAsciiDoc _ (Math DisplayMath str) = do
isAsciidoctor <- gets asciidoctorVariant
+ modify $ \st -> st{ hasMath = True }
let content = if isAsciidoctor
then text str
else "\\[" <> text str <> "\\]"