@@ -48,11 +48,12 @@ import Data.Char (isSpace, toLower)
4848type Refs = [([Inline], Target)]
4949
5050data WriterState =
51− WriterState { stNotes :: [[Block]]
52− , stLinks :: Refs
53− , stImages :: [([Inline], (String, String, Maybe String))]
54− , stHasMath :: Bool
55− , stOptions :: WriterOptions
51+ WriterState { stNotes :: [[Block]]
52+ , stLinks :: Refs
53+ , stImages :: [([Inline], (String, String, Maybe String))]
54+ , stHasMath :: Bool
55+ , stHasRawTeX :: Bool
56+ , stOptions :: WriterOptions
5657 }
5758
5859-- | Convert Pandoc to RST.
@@ -60,7 +61,7 @@ writeRST :: WriterOptions -> Pandoc -> String
6061writeRST opts document =
6162 let st = WriterState { stNotes = [], stLinks = [],
6263 stImages = [], stHasMath = False,
63− stOptions = opts }
64+ stHasRawTeX = False, stOptions = opts }
6465 in evalState (pandocToRST document) st
6566
6667-- | Return RST representation of document.
@@ -84,6 +85,7 @@ pandocToRST (Pandoc meta blocks) = do
8485 refs <- liftM (reverse . stLinks) get >>= refsToRST
8586 pics <- liftM (reverse . stImages) get >>= pictRefsToRST
8687 hasMath <- liftM stHasMath get
88+ rawTeX <- liftM stHasRawTeX get
8789 let main = render colwidth $ foldl ($+$) empty $ [body, notes, refs, pics]
8890 let context = defField "body" main
8991 $ defField "toc" (writerTableOfContents opts)
@@ -91,6 +93,7 @@ pandocToRST (Pandoc meta blocks) = do
9193 $ defField "math" hasMath
9294 $ defField "title" (render Nothing title :: String)
9395 $ defField "math" hasMath
96+ $ defField "rawtex" rawTeX
9497 $ metadata
9598 if writerStandalone opts
9699 then return $ renderTemplate' (writerTemplate opts) context
@@ -392,6 +395,9 @@ inlineToRST (Math t str) = do
392395 else blankline $$ (".. math:: " <> text str) $$ blankline
393396inlineToRST (RawInline f x)
394397 | f == "rst" = return $ text x
398+ | f == "latex" || f == "tex" = do
399+ modify $ \st -> st{ stHasRawTeX = True }
400+ return $ ":raw-latex:`" <> text x <> "`"
395401 | otherwise = return empty
396402inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para)
397403inlineToRST Space = return space