Asciidoctor writer sets the stem attribute if it contains latexmath
This commit is contained in:
parent
568b25d33a
commit
8c2e2435f9
3 changed files with 11 additions and 1 deletions
|
@ -15,6 +15,9 @@ $endif$
|
||||||
$if(toc)$
|
$if(toc)$
|
||||||
:toc:
|
:toc:
|
||||||
$endif$
|
$endif$
|
||||||
|
$if(math)$
|
||||||
|
:stem: latexmath
|
||||||
|
$endif$
|
||||||
|
|
||||||
$endif$
|
$endif$
|
||||||
$if(abstract)$
|
$if(abstract)$
|
||||||
|
|
|
@ -62,6 +62,7 @@ data WriterState = WriterState { defListMarker :: String
|
||||||
, intraword :: Bool
|
, intraword :: Bool
|
||||||
, autoIds :: Set.Set String
|
, autoIds :: Set.Set String
|
||||||
, asciidoctorVariant :: Bool
|
, asciidoctorVariant :: Bool
|
||||||
|
, hasMath :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultWriterState :: WriterState
|
defaultWriterState :: WriterState
|
||||||
|
@ -71,6 +72,7 @@ defaultWriterState = WriterState { defListMarker = "::"
|
||||||
, intraword = False
|
, intraword = False
|
||||||
, autoIds = Set.empty
|
, autoIds = Set.empty
|
||||||
, asciidoctorVariant = False
|
, asciidoctorVariant = False
|
||||||
|
, hasMath = False
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Convert Pandoc to AsciiDoc.
|
-- | Convert Pandoc to AsciiDoc.
|
||||||
|
@ -101,11 +103,13 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
|
||||||
meta
|
meta
|
||||||
body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
|
body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
|
||||||
let main = render colwidth body
|
let main = render colwidth body
|
||||||
|
st <- get
|
||||||
let context = defField "body" main
|
let context = defField "body" main
|
||||||
$ defField "toc"
|
$ defField "toc"
|
||||||
(writerTableOfContents opts &&
|
(writerTableOfContents opts &&
|
||||||
isJust (writerTemplate opts))
|
isJust (writerTemplate opts))
|
||||||
$defField "titleblock" titleblock metadata
|
$ defField "math" (hasMath st)
|
||||||
|
$ defField "titleblock" titleblock metadata
|
||||||
case writerTemplate opts of
|
case writerTemplate opts of
|
||||||
Nothing -> return main
|
Nothing -> return main
|
||||||
Just tpl -> renderTemplate' tpl context
|
Just tpl -> renderTemplate' tpl context
|
||||||
|
@ -422,12 +426,14 @@ inlineToAsciiDoc _ (Code _ str) = return $
|
||||||
inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
|
inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
|
||||||
inlineToAsciiDoc _ (Math InlineMath str) = do
|
inlineToAsciiDoc _ (Math InlineMath str) = do
|
||||||
isAsciidoctor <- gets asciidoctorVariant
|
isAsciidoctor <- gets asciidoctorVariant
|
||||||
|
modify $ \st -> st{ hasMath = True }
|
||||||
let content = if isAsciidoctor
|
let content = if isAsciidoctor
|
||||||
then text str
|
then text str
|
||||||
else "$" <> text str <> "$"
|
else "$" <> text str <> "$"
|
||||||
return $ "latexmath:[" <> content <> "]"
|
return $ "latexmath:[" <> content <> "]"
|
||||||
inlineToAsciiDoc _ (Math DisplayMath str) = do
|
inlineToAsciiDoc _ (Math DisplayMath str) = do
|
||||||
isAsciidoctor <- gets asciidoctorVariant
|
isAsciidoctor <- gets asciidoctorVariant
|
||||||
|
modify $ \st -> st{ hasMath = True }
|
||||||
let content = if isAsciidoctor
|
let content = if isAsciidoctor
|
||||||
then text str
|
then text str
|
||||||
else "\\[" <> text str <> "\\]"
|
else "\\[" <> text str <> "\\]"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
= Pandoc Test Suite
|
= Pandoc Test Suite
|
||||||
John MacFarlane; Anonymous
|
John MacFarlane; Anonymous
|
||||||
July 17, 2006
|
July 17, 2006
|
||||||
|
:stem: latexmath
|
||||||
|
|
||||||
This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
|
This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
|
||||||
markdown test suite.
|
markdown test suite.
|
||||||
|
|
Loading…
Add table
Reference in a new issue