summaryrefslogtreecommitdiff
path: root/Text/Pandoc/Writers
diff options
context:
space:
mode:
Diffstat (limited to 'Text/Pandoc/Writers')
-rw-r--r--Text/Pandoc/Writers/Docbook.hs3
-rw-r--r--Text/Pandoc/Writers/HTML.hs19
-rw-r--r--Text/Pandoc/Writers/Man.hs5
-rw-r--r--Text/Pandoc/Writers/RST.hs7
-rw-r--r--Text/Pandoc/Writers/RTF.hs3
5 files changed, 19 insertions, 18 deletions
diff --git a/Text/Pandoc/Writers/Docbook.hs b/Text/Pandoc/Writers/Docbook.hs
index 2cad0ca39..f0fde18a4 100644
--- a/Text/Pandoc/Writers/Docbook.hs
+++ b/Text/Pandoc/Writers/Docbook.hs
@@ -30,6 +30,7 @@ Conversion of 'Pandoc' documents to Docbook XML.
module Text.Pandoc.Writers.Docbook ( writeDocbook) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
+import Text.Pandoc.Readers.TeXMath
import Data.List ( isPrefixOf, drop )
import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -274,7 +275,7 @@ inlineToDocbook opts EmDash = text "—"
inlineToDocbook opts EnDash = text "–"
inlineToDocbook opts (Code str) =
inTagsSimple "literal" $ text (escapeStringForXML str)
-inlineToDocbook opts (Math str) = inlineToDocbook opts (Code str)
+inlineToDocbook opts (Math str) = inlinesToDocbook opts $ readTeXMath str
inlineToDocbook opts (TeX str) = empty
inlineToDocbook opts (HtmlInline str) = empty
inlineToDocbook opts LineBreak = text $ "<literallayout></literallayout>"
diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs
index 881e3c07c..70814eb15 100644
--- a/Text/Pandoc/Writers/HTML.hs
+++ b/Text/Pandoc/Writers/HTML.hs
@@ -32,6 +32,7 @@ import Text.Pandoc.Definition
import Text.Pandoc.ASCIIMathML
import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
import Text.Pandoc.Shared
+import Text.Pandoc.Readers.TeXMath
import Text.Regex ( mkRegex, matchRegex )
import Numeric ( showHex )
import Data.Char ( ord, toLower )
@@ -401,16 +402,16 @@ inlineToHtml opts inline =
in do contents <- inlineListToHtml opts lst
return $ leftQuote +++ contents +++ rightQuote
(Math str) -> modify (\st -> st {stMath = True}) >>
- (return $ case writerHTMLMathMethod opts of
- ASCIIMathML _ ->
- stringToHtml ("$" ++ str ++ "$")
- MimeTeX url ->
- image ! [src (url ++ "?" ++ str),
+ (case writerHTMLMathMethod opts of
+ ASCIIMathML _ ->
+ return $ stringToHtml ("$" ++ str ++ "$")
+ MimeTeX url ->
+ return $ image ! [src (url ++ "?" ++ str),
alt str, title str]
- GladTeX ->
- tag "eq" << str
- PlainMath ->
- stringToHtml str)
+ GladTeX ->
+ return $ tag "eq" << str
+ PlainMath ->
+ inlineListToHtml opts (readTeXMath str))
(TeX str) -> return noHtml
(HtmlInline str) -> return $ primHtml str
(Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src ->
diff --git a/Text/Pandoc/Writers/Man.hs b/Text/Pandoc/Writers/Man.hs
index 899cd9f57..bd170f6ba 100644
--- a/Text/Pandoc/Writers/Man.hs
+++ b/Text/Pandoc/Writers/Man.hs
@@ -30,7 +30,8 @@ Conversion of 'Pandoc' documents to groff man page format.
-}
module Text.Pandoc.Writers.Man ( writeMan) where
import Text.Pandoc.Definition
-import Text.Pandoc.Shared
+import Text.Pandoc.Shared
+import Text.Pandoc.Readers.TeXMath
import Text.Printf ( printf )
import Data.List ( isPrefixOf, drop, nub, intersperse )
import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -268,7 +269,7 @@ inlineToMan opts Ellipses = return $ text "\\&..."
inlineToMan opts (Code str) =
return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]"
inlineToMan opts (Str str) = return $ text $ escapeString str
-inlineToMan opts (Math str) = return $ text $ escapeCode str
+inlineToMan opts (Math str) = inlineToMan opts (Code str)
inlineToMan opts (TeX str) = return empty
inlineToMan opts (HtmlInline str) = return $ text $ escapeCode str
inlineToMan opts (LineBreak) = return $ text "\n.PD 0\n.P\n.PD\n"
diff --git a/Text/Pandoc/Writers/RST.hs b/Text/Pandoc/Writers/RST.hs
index 4a7242d1f..7dd99f2ea 100644
--- a/Text/Pandoc/Writers/RST.hs
+++ b/Text/Pandoc/Writers/RST.hs
@@ -32,6 +32,7 @@ reStructuredText: <http://docutils.sourceforge.net/rst.html>
module Text.Pandoc.Writers.RST ( writeRST) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
+import Text.Pandoc.Readers.TeXMath
import Text.Pandoc.Blocks
import Data.List ( isPrefixOf, isSuffixOf, drop, intersperse )
import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -151,10 +152,6 @@ blockToRST :: WriterOptions -- ^ Options
-> State WriterState Doc
blockToRST opts Null = return empty
blockToRST opts (Plain inlines) = wrappedRST opts inlines
-blockToRST opts (Para [Math str]) =
- let str' = if "\n" `isSuffixOf` str then str ++ "\n" else str ++ "\n\n" in
- return $ hang (text "\n.. raw:: latex\n") 3 $ text "\\[" <>
- (vcat $ map text (lines str')) <> text "\\]"
blockToRST opts (Para inlines) = do
contents <- wrappedRST opts inlines
return $ contents <> text "\n"
@@ -286,7 +283,7 @@ inlineToRST opts Apostrophe = return $ char '\''
inlineToRST opts Ellipses = return $ text "..."
inlineToRST opts (Code str) = return $ text $ "``" ++ str ++ "``"
inlineToRST opts (Str str) = return $ text $ escapeString str
-inlineToRST opts (Math str) = return $ char '$' <> text str <> char '$'
+inlineToRST opts (Math str) = return $ text $ "$" ++ str ++ "$"
inlineToRST opts (TeX str) = return empty
inlineToRST opts (HtmlInline str) = return empty
inlineToRST opts (LineBreak) = return $ char ' ' -- RST doesn't have linebreaks
diff --git a/Text/Pandoc/Writers/RTF.hs b/Text/Pandoc/Writers/RTF.hs
index 9c5e6cbd3..64d73a30f 100644
--- a/Text/Pandoc/Writers/RTF.hs
+++ b/Text/Pandoc/Writers/RTF.hs
@@ -30,6 +30,7 @@ Conversion of 'Pandoc' documents to RTF (rich text format).
module Text.Pandoc.Writers.RTF ( writeRTF ) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
+import Text.Pandoc.Readers.TeXMath
import Text.Regex ( matchRegexAll, mkRegex )
import Data.List ( isSuffixOf )
import Data.Char ( ord )
@@ -272,7 +273,7 @@ inlineToRTF EmDash = "\\u8212-"
inlineToRTF EnDash = "\\u8211-"
inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "} "
inlineToRTF (Str str) = stringToRTF str
-inlineToRTF (Math str) = latexToRTF str
+inlineToRTF (Math str) = inlineListToRTF $ readTeXMath str
inlineToRTF (TeX str) = ""
inlineToRTF (HtmlInline str) = ""
inlineToRTF (LineBreak) = "\\line "