diff options
m--------- | data/templates | 12 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 18 | ||||
-rw-r--r-- | tests/writer.rst | 6 |
3 files changed, 22 insertions, 14 deletions
diff --git a/data/templates b/data/templates -Subproject bed3f14dbc53f8dc69a542547d2858bb06c6fa9 +Subproject 7846f08b61167b0364722d440e06a432ade8530 diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 717a47000..7d1e22baa 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -48,11 +48,12 @@ import Data.Char (isSpace, toLower) type Refs = [([Inline], Target)] data WriterState = - WriterState { stNotes :: [[Block]] - , stLinks :: Refs - , stImages :: [([Inline], (String, String, Maybe String))] - , stHasMath :: Bool - , stOptions :: WriterOptions + WriterState { stNotes :: [[Block]] + , stLinks :: Refs + , stImages :: [([Inline], (String, String, Maybe String))] + , stHasMath :: Bool + , stHasRawTeX :: Bool + , stOptions :: WriterOptions } -- | Convert Pandoc to RST. @@ -60,7 +61,7 @@ writeRST :: WriterOptions -> Pandoc -> String writeRST opts document = let st = WriterState { stNotes = [], stLinks = [], stImages = [], stHasMath = False, - stOptions = opts } + stHasRawTeX = False, stOptions = opts } in evalState (pandocToRST document) st -- | Return RST representation of document. @@ -84,6 +85,7 @@ pandocToRST (Pandoc meta blocks) = do refs <- liftM (reverse . stLinks) get >>= refsToRST pics <- liftM (reverse . stImages) get >>= pictRefsToRST hasMath <- liftM stHasMath get + rawTeX <- liftM stHasRawTeX get let main = render colwidth $ foldl ($+$) empty $ [body, notes, refs, pics] let context = defField "body" main $ defField "toc" (writerTableOfContents opts) @@ -91,6 +93,7 @@ pandocToRST (Pandoc meta blocks) = do $ defField "math" hasMath $ defField "title" (render Nothing title :: String) $ defField "math" hasMath + $ defField "rawtex" rawTeX $ metadata if writerStandalone opts then return $ renderTemplate' (writerTemplate opts) context @@ -392,6 +395,9 @@ inlineToRST (Math t str) = do else blankline $$ (".. math:: " <> text str) $$ blankline inlineToRST (RawInline f x) | f == "rst" = return $ text x + | f == "latex" || f == "tex" = do + modify $ \st -> st{ stHasRawTeX = True } + return $ ":raw-latex:`" <> text x <> "`" | otherwise = return empty inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para) inlineToRST Space = return space diff --git a/tests/writer.rst b/tests/writer.rst index f09871a34..1aeeacacb 100644 --- a/tests/writer.rst +++ b/tests/writer.rst @@ -10,6 +10,10 @@ Pandoc Test Suite :format: html latex .. +.. role:: raw-latex(raw) + :format: latex +.. + This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite. @@ -657,7 +661,7 @@ Ellipses…and…and…. LaTeX ===== -- +- :raw-latex:`\cite[22-23]{smith.1899}` - :math:`2+2=4` - :math:`x \in y` - :math:`\alpha \wedge \omega` |