git.iko.soy/typeable/pandoc
on master help sign in
Asciidoctor writer sets the stem attribute if it contains latexmath
commit8c2e2435f9f9d4ae92ec28a017d26e1c4a834393 authorTG <tarik.graba@telecom-paristech.fr> dateThu 7 Feb 2019, 19:01 (8 years ago) parent568b25d
3 files changed+11−1
data/templates/default.asciidoctor+3 src/Text/Pandoc/Writers/AsciiDoc.hs+7−1 test/writer.asciidoctor+1
data/templates/default.asciidoctor+3
@@ -15,6 +15,9 @@ $endif$
1515$if(toc)$
1616:toc:
1717$endif$
18+$if(math)$
19+:stem: latexmath
20+$endif$
1821
1922$endif$
2023$if(abstract)$
src/Text/Pandoc/Writers/AsciiDoc.hs+7−1
@@ -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 <> "\\]"
test/writer.asciidoctor+1
@@ -1,6 +1,7 @@
11= Pandoc Test Suite
22John MacFarlane; Anonymous
33July 17, 2006
4+:stem: latexmath
45
56This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
67markdown test suite.