git.iko.soy/typeable/pandoc
on master help sign in
Asciidoctor writer sets the stem attribute if it contains latexmath
8c2e243TG
data/templates/default.asciidoctor+3
@@ -15,6 +15,9 @@ $endif$
15$if(toc)$
15$if(toc)$
16:toc:
16:toc:
17$endif$
17$endif$
18+$if(math)$
19+:stem: latexmath
20+$endif$
18
21
19$endif$
22$endif$
20$if(abstract)$
23$if(abstract)$
src/Text/Pandoc/Writers/AsciiDoc.hs+7−1
@@ -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
65+ , hasMath :: Bool
65 }
66 }
66
67
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
75+ , hasMath = False
74 }
76 }
75
77
76-- | Convert Pandoc to AsciiDoc.
78-- | Convert Pandoc to AsciiDoc.
@@ -101,11 +103,13 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
101 meta
103 meta
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
106+ st <- get
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 <> "\\]"
test/writer.asciidoctor+1
@@ -1,6 +1,7 @@
1= Pandoc Test Suite
1= Pandoc Test Suite
2John MacFarlane; Anonymous
2John MacFarlane; Anonymous
3July 17, 2006
3July 17, 2006
4+:stem: latexmath
4
5
5This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
6This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
6markdown test suite.
7markdown test suite.