@@ -62,6 +62,7 @@ data WriterState = WriterState { defListMarker :: String
6262 , intraword :: Bool
6363 , autoIds :: Set.Set String
6464 , asciidoctorVariant :: Bool
65+ , hasMath :: Bool
6566 }
6667
6768defaultWriterState :: WriterState
@@ -71,6 +72,7 @@ defaultWriterState = WriterState { defListMarker = "::"
7172 , intraword = False
7273 , autoIds = Set.empty
7374 , asciidoctorVariant = False
75+ , hasMath = False
7476 }
7577
7678-- | Convert Pandoc to AsciiDoc.
@@ -101,11 +103,13 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
101103 meta
102104 body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
103105 let main = render colwidth body
106+ st <- get
104107 let context = defField "body" main
105108 $ defField "toc"
106109 (writerTableOfContents opts &&
107110 isJust (writerTemplate opts))
108− $defField "titleblock" titleblock metadata
111+ $ defField "math" (hasMath st)
112+ $ defField "titleblock" titleblock metadata
109113 case writerTemplate opts of
110114 Nothing -> return main
111115 Just tpl -> renderTemplate' tpl context
@@ -422,12 +426,14 @@ inlineToAsciiDoc _ (Code _ str) = return $
422426inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
423427inlineToAsciiDoc _ (Math InlineMath str) = do
424428 isAsciidoctor <- gets asciidoctorVariant
429+ modify $ \st -> st{ hasMath = True }
425430 let content = if isAsciidoctor
426431 then text str
427432 else "$" <> text str <> "$"
428433 return $ "latexmath:[" <> content <> "]"
429434inlineToAsciiDoc _ (Math DisplayMath str) = do
430435 isAsciidoctor <- gets asciidoctorVariant
436+ modify $ \st -> st{ hasMath = True }
431437 let content = if isAsciidoctor
432438 then text str
433439 else "\\[" <> text str <> "\\]"