diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-11-29 08:09:31 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-11-29 08:09:31 +0000 |
commit | 03f4a665ffbf8f8aeba6b319649d6dcd0841bc1c (patch) | |
tree | bb8ce30e722a32543ca4113b6ccaa52d523747e7 | |
parent | 132186e6b0cf06ee20334d885c55e9e357e0c3b2 (diff) | |
download | pandoc-03f4a665ffbf8f8aeba6b319649d6dcd0841bc1c.tar.gz |
Changed all writers to handle new Math block element.
This allows TeX element to be handled differently (and in
many output formats, simply ignored).
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1118 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | Text/Pandoc/Writers/ConTeXt.hs | 1 | ||||
-rw-r--r-- | Text/Pandoc/Writers/Docbook.hs | 3 | ||||
-rw-r--r-- | Text/Pandoc/Writers/HTML.hs | 7 | ||||
-rw-r--r-- | Text/Pandoc/Writers/LaTeX.hs | 1 | ||||
-rw-r--r-- | Text/Pandoc/Writers/Man.hs | 3 | ||||
-rw-r--r-- | Text/Pandoc/Writers/Markdown.hs | 1 | ||||
-rw-r--r-- | Text/Pandoc/Writers/RST.hs | 8 | ||||
-rw-r--r-- | Text/Pandoc/Writers/RTF.hs | 3 |
8 files changed, 19 insertions, 8 deletions
diff --git a/Text/Pandoc/Writers/ConTeXt.hs b/Text/Pandoc/Writers/ConTeXt.hs index 98252f172..1ea17272d 100644 --- a/Text/Pandoc/Writers/ConTeXt.hs +++ b/Text/Pandoc/Writers/ConTeXt.hs @@ -271,6 +271,7 @@ inlineToConTeXt EmDash = return $ text "---" inlineToConTeXt EnDash = return $ text "--" inlineToConTeXt Ellipses = return $ text "\\ldots{}" inlineToConTeXt (Str str) = return $ text $ stringToConTeXt str +inlineToConTeXt (Math str) = return $ char '$' <> text str <> char '$' inlineToConTeXt (TeX str) = return $ text str inlineToConTeXt (HtmlInline str) = return empty inlineToConTeXt (LineBreak) = return $ text "\\crlf\n" diff --git a/Text/Pandoc/Writers/Docbook.hs b/Text/Pandoc/Writers/Docbook.hs index 13dc8585d..2cad0ca39 100644 --- a/Text/Pandoc/Writers/Docbook.hs +++ b/Text/Pandoc/Writers/Docbook.hs @@ -274,7 +274,8 @@ inlineToDocbook opts EmDash = text "—" inlineToDocbook opts EnDash = text "–" inlineToDocbook opts (Code str) = inTagsSimple "literal" $ text (escapeStringForXML str) -inlineToDocbook opts (TeX str) = inlineToDocbook opts (Code str) +inlineToDocbook opts (Math str) = inlineToDocbook opts (Code str) +inlineToDocbook opts (TeX str) = empty inlineToDocbook opts (HtmlInline str) = empty inlineToDocbook opts LineBreak = text $ "<literallayout></literallayout>" inlineToDocbook opts Space = char ' ' diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 7ec95d8ef..b933064fc 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -230,6 +230,7 @@ inlineListToIdentifier (x:xs) = Apostrophe -> "" Ellipses -> "" LineBreak -> "-" + Math _ -> "" TeX _ -> "" HtmlInline _ -> "" Link lst _ -> inlineListToIdentifier lst @@ -396,9 +397,11 @@ inlineToHtml opts inline = primHtmlChar "rdquo") in do contents <- inlineListToHtml opts lst return $ leftQuote +++ contents +++ rightQuote - (TeX str) -> (if writerUseASCIIMathML opts + (Math str) -> (if writerUseASCIIMathML opts then modify (\st -> st {stMath = True}) - else return ()) >> return (stringToHtml str) + else return ()) >> + return (stringToHtml ("$" ++ str ++ "$")) + (TeX str) -> return noHtml (HtmlInline str) -> return $ primHtml str (Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src -> return $ obfuscateLink opts str src diff --git a/Text/Pandoc/Writers/LaTeX.hs b/Text/Pandoc/Writers/LaTeX.hs index 88050cc65..d66a66941 100644 --- a/Text/Pandoc/Writers/LaTeX.hs +++ b/Text/Pandoc/Writers/LaTeX.hs @@ -290,6 +290,7 @@ inlineToLaTeX EmDash = return $ text "---" inlineToLaTeX EnDash = return $ text "--" inlineToLaTeX Ellipses = return $ text "\\ldots{}" inlineToLaTeX (Str str) = return $ text $ stringToLaTeX str +inlineToLaTeX (Math str) = return $ char '$' <> text str <> char '$' inlineToLaTeX (TeX str) = return $ text str inlineToLaTeX (HtmlInline str) = return empty inlineToLaTeX (LineBreak) = return $ text "\\\\" diff --git a/Text/Pandoc/Writers/Man.hs b/Text/Pandoc/Writers/Man.hs index 8e14c2bf0..899cd9f57 100644 --- a/Text/Pandoc/Writers/Man.hs +++ b/Text/Pandoc/Writers/Man.hs @@ -268,7 +268,8 @@ 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 (TeX str) = return $ text $ escapeCode str +inlineToMan opts (Math str) = return $ text $ escapeCode 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" inlineToMan opts Space = return $ char ' ' diff --git a/Text/Pandoc/Writers/Markdown.hs b/Text/Pandoc/Writers/Markdown.hs index 4cecaae5d..23cd7e86e 100644 --- a/Text/Pandoc/Writers/Markdown.hs +++ b/Text/Pandoc/Writers/Markdown.hs @@ -337,6 +337,7 @@ inlineToMarkdown opts (Code str) = spacer = if (longest == 0) then "" else " " in return $ text (marker ++ spacer ++ str ++ spacer ++ marker) inlineToMarkdown opts (Str str) = return $ text $ escapeString str +inlineToMarkdown opts (Math str) = return $ char '$' <> text str <> char '$' inlineToMarkdown opts (TeX str) = return $ text str inlineToMarkdown opts (HtmlInline str) = return $ text str inlineToMarkdown opts (LineBreak) = return $ text " \n" diff --git a/Text/Pandoc/Writers/RST.hs b/Text/Pandoc/Writers/RST.hs index ddcbf95c0..4a7242d1f 100644 --- a/Text/Pandoc/Writers/RST.hs +++ b/Text/Pandoc/Writers/RST.hs @@ -151,9 +151,10 @@ blockToRST :: WriterOptions -- ^ Options -> State WriterState Doc blockToRST opts Null = return empty blockToRST opts (Plain inlines) = wrappedRST opts inlines -blockToRST opts (Para [TeX str]) = +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 $ vcat $ map text (lines str') + 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" @@ -285,7 +286,8 @@ 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 (TeX str) = return $ text str +inlineToRST opts (Math str) = return $ char '$' <> text str <> char '$' +inlineToRST opts (TeX str) = return empty inlineToRST opts (HtmlInline str) = return empty inlineToRST opts (LineBreak) = return $ char ' ' -- RST doesn't have linebreaks inlineToRST opts Space = return $ char ' ' diff --git a/Text/Pandoc/Writers/RTF.hs b/Text/Pandoc/Writers/RTF.hs index 3bd5c63b2..9c5e6cbd3 100644 --- a/Text/Pandoc/Writers/RTF.hs +++ b/Text/Pandoc/Writers/RTF.hs @@ -272,7 +272,8 @@ inlineToRTF EmDash = "\\u8212-" inlineToRTF EnDash = "\\u8211-" inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "} " inlineToRTF (Str str) = stringToRTF str -inlineToRTF (TeX str) = latexToRTF str +inlineToRTF (Math str) = latexToRTF str +inlineToRTF (TeX str) = "" inlineToRTF (HtmlInline str) = "" inlineToRTF (LineBreak) = "\\line " inlineToRTF Space = " " |