@@ -62,6 +62,7 @@ data WriterState = WriterState { defListMarker :: String
62 , intraword :: Bool
62 , intraword :: Bool
63 , autoIds :: Set.Set String
63 , autoIds :: Set.Set String
64 , asciidoctorVariant :: Bool
64 , asciidoctorVariant :: Bool
67defaultWriterState :: WriterState
68defaultWriterState :: WriterState
@@ -71,6 +72,7 @@ defaultWriterState = WriterState { defListMarker = "::"
71 , intraword = False
72 , intraword = False
72 , autoIds = Set.empty
73 , autoIds = Set.empty
73 , asciidoctorVariant = False
74 , asciidoctorVariant = False
76-- | Convert Pandoc to AsciiDoc.
78-- | Convert Pandoc to AsciiDoc.
@@ -101,11 +103,13 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
102 body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
104 body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
103 let main = render colwidth body
105 let main = render colwidth body
104 let context = defField "body" main
107 let context = defField "body" main
105 $ defField "toc"
108 $ defField "toc"
106 (writerTableOfContents opts &&
109 (writerTableOfContents opts &&
107 isJust (writerTemplate opts))
110 isJust (writerTemplate opts))
111+ $ defField "math" (hasMath st)
108− $defField "titleblock" titleblock metadata
112+ $ defField "titleblock" titleblock metadata
109 case writerTemplate opts of
113 case writerTemplate opts of
110 Nothing -> return main
114 Nothing -> return main
111 Just tpl -> renderTemplate' tpl context
115 Just tpl -> renderTemplate' tpl context
@@ -422,12 +426,14 @@ inlineToAsciiDoc _ (Code _ str) = return $
422inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
426inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
423inlineToAsciiDoc _ (Math InlineMath str) = do
427inlineToAsciiDoc _ (Math InlineMath str) = do
424 isAsciidoctor <- gets asciidoctorVariant
428 isAsciidoctor <- gets asciidoctorVariant
429+ modify $ \st -> st{ hasMath = True }
425 let content = if isAsciidoctor
430 let content = if isAsciidoctor
426 then text str
431 then text str
427 else "$" <> text str <> "$"
432 else "$" <> text str <> "$"
428 return $ "latexmath:[" <> content <> "]"
433 return $ "latexmath:[" <> content <> "]"
429inlineToAsciiDoc _ (Math DisplayMath str) = do
434inlineToAsciiDoc _ (Math DisplayMath str) = do
430 isAsciidoctor <- gets asciidoctorVariant
435 isAsciidoctor <- gets asciidoctorVariant
436+ modify $ \st -> st{ hasMath = True }
431 let content = if isAsciidoctor
437 let content = if isAsciidoctor
432 then text str
438 then text str
433 else "\\[" <> text str <> "\\]"
439 else "\\[" <> text str <> "\\]"