git.iko.soy/typeable/pandoc
on master help sign in
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

commit03f4a665ffbf8f8aeba6b319649d6dcd0841bc1c authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 29 Nov 2007, 08:09 (19 years ago) parent132186e
8 files changed+19−8
Text/Pandoc/Writers/ConTeXt.hs+1 Text/Pandoc/Writers/Docbook.hs+2−1 Text/Pandoc/Writers/HTML.hs+5−2 Text/Pandoc/Writers/LaTeX.hs+1 Text/Pandoc/Writers/Man.hs+2−1 Text/Pandoc/Writers/Markdown.hs+1 Text/Pandoc/Writers/RST.hs+5−3 Text/Pandoc/Writers/RTF.hs+2−1
Text/Pandoc/Writers/ConTeXt.hs+1
@@ -271,6 +271,7 @@ inlineToConTeXt EmDash = return $ text "---"
271271inlineToConTeXt EnDash = return $ text "--"
272272inlineToConTeXt Ellipses = return $ text "\\ldots{}"
273273inlineToConTeXt (Str str) = return $ text $ stringToConTeXt str
274+inlineToConTeXt (Math str) = return $ char '$' <> text str <> char '$'
274275inlineToConTeXt (TeX str) = return $ text str
275276inlineToConTeXt (HtmlInline str) = return empty
276277inlineToConTeXt (LineBreak) = return $ text "\\crlf\n"
Text/Pandoc/Writers/Docbook.hs+2−1
@@ -274,7 +274,8 @@ inlineToDocbook opts EmDash = text "&#8212;"
274274inlineToDocbook opts EnDash = text "&#8211;"
275275inlineToDocbook opts (Code str) =
276276 inTagsSimple "literal" $ text (escapeStringForXML str)
277−inlineToDocbook opts (TeX str) = inlineToDocbook opts (Code str)
277+inlineToDocbook opts (Math str) = inlineToDocbook opts (Code str)
278+inlineToDocbook opts (TeX str) = empty
278279inlineToDocbook opts (HtmlInline str) = empty
279280inlineToDocbook opts LineBreak = text $ "<literallayout></literallayout>"
280281inlineToDocbook opts Space = char ' '
Text/Pandoc/Writers/HTML.hs+5−2
@@ -230,6 +230,7 @@ inlineListToIdentifier (x:xs) =
230230 Apostrophe -> ""
231231 Ellipses -> ""
232232 LineBreak -> "-"
233+ Math _ -> ""
233234 TeX _ -> ""
234235 HtmlInline _ -> ""
235236 Link lst _ -> inlineListToIdentifier lst
@@ -396,9 +397,11 @@ inlineToHtml opts inline =
396397 primHtmlChar "rdquo")
397398 in do contents <- inlineListToHtml opts lst
398399 return $ leftQuote +++ contents +++ rightQuote
399− (TeX str) -> (if writerUseASCIIMathML opts
400+ (Math str) -> (if writerUseASCIIMathML opts
400401 then modify (\st -> st {stMath = True})
401− else return ()) >> return (stringToHtml str)
402+ else return ()) >>
403+ return (stringToHtml ("$" ++ str ++ "$"))
404+ (TeX str) -> return noHtml
402405 (HtmlInline str) -> return $ primHtml str
403406 (Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src ->
404407 return $ obfuscateLink opts str src
Text/Pandoc/Writers/LaTeX.hs+1
@@ -290,6 +290,7 @@ inlineToLaTeX EmDash = return $ text "---"
290290inlineToLaTeX EnDash = return $ text "--"
291291inlineToLaTeX Ellipses = return $ text "\\ldots{}"
292292inlineToLaTeX (Str str) = return $ text $ stringToLaTeX str
293+inlineToLaTeX (Math str) = return $ char '$' <> text str <> char '$'
293294inlineToLaTeX (TeX str) = return $ text str
294295inlineToLaTeX (HtmlInline str) = return empty
295296inlineToLaTeX (LineBreak) = return $ text "\\\\"
Text/Pandoc/Writers/Man.hs+2−1
@@ -268,7 +268,8 @@ inlineToMan opts Ellipses = return $ text "\\&..."
268268inlineToMan opts (Code str) =
269269 return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]"
270270inlineToMan opts (Str str) = return $ text $ escapeString str
271−inlineToMan opts (TeX str) = return $ text $ escapeCode str
271+inlineToMan opts (Math str) = return $ text $ escapeCode str
272+inlineToMan opts (TeX str) = return empty
272273inlineToMan opts (HtmlInline str) = return $ text $ escapeCode str
273274inlineToMan opts (LineBreak) = return $ text "\n.PD 0\n.P\n.PD\n"
274275inlineToMan opts Space = return $ char ' '
Text/Pandoc/Writers/Markdown.hs+1
@@ -337,6 +337,7 @@ inlineToMarkdown opts (Code str) =
337337 spacer = if (longest == 0) then "" else " " in
338338 return $ text (marker ++ spacer ++ str ++ spacer ++ marker)
339339inlineToMarkdown opts (Str str) = return $ text $ escapeString str
340+inlineToMarkdown opts (Math str) = return $ char '$' <> text str <> char '$'
340341inlineToMarkdown opts (TeX str) = return $ text str
341342inlineToMarkdown opts (HtmlInline str) = return $ text str
342343inlineToMarkdown opts (LineBreak) = return $ text " \n"
Text/Pandoc/Writers/RST.hs+5−3
@@ -151,9 +151,10 @@ blockToRST :: WriterOptions -- ^ Options
151151 -> State WriterState Doc
152152blockToRST opts Null = return empty
153153blockToRST opts (Plain inlines) = wrappedRST opts inlines
154−blockToRST opts (Para [TeX str]) =
154+blockToRST opts (Para [Math str]) =
155155 let str' = if "\n" `isSuffixOf` str then str ++ "\n" else str ++ "\n\n" in
156− return $ hang (text "\n.. raw:: latex\n") 3 $ vcat $ map text (lines str')
156+ return $ hang (text "\n.. raw:: latex\n") 3 $ text "\\[" <>
157+ (vcat $ map text (lines str')) <> text "\\]"
157158blockToRST opts (Para inlines) = do
158159 contents <- wrappedRST opts inlines
159160 return $ contents <> text "\n"
@@ -285,7 +286,8 @@ inlineToRST opts Apostrophe = return $ char '\''
285286inlineToRST opts Ellipses = return $ text "..."
286287inlineToRST opts (Code str) = return $ text $ "``" ++ str ++ "``"
287288inlineToRST opts (Str str) = return $ text $ escapeString str
288−inlineToRST opts (TeX str) = return $ text str
289+inlineToRST opts (Math str) = return $ char '$' <> text str <> char '$'
290+inlineToRST opts (TeX str) = return empty
289291inlineToRST opts (HtmlInline str) = return empty
290292inlineToRST opts (LineBreak) = return $ char ' ' -- RST doesn't have linebreaks
291293inlineToRST opts Space = return $ char ' '
Text/Pandoc/Writers/RTF.hs+2−1
@@ -272,7 +272,8 @@ inlineToRTF EmDash = "\\u8212-"
272272inlineToRTF EnDash = "\\u8211-"
273273inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "} "
274274inlineToRTF (Str str) = stringToRTF str
275−inlineToRTF (TeX str) = latexToRTF str
275+inlineToRTF (Math str) = latexToRTF str
276+inlineToRTF (TeX str) = ""
276277inlineToRTF (HtmlInline str) = ""
277278inlineToRTF (LineBreak) = "\\line "
278279inlineToRTF Space = " "