git.iko.soy/typeable/pandoc
on master help sign in
Renamed readTeXMath' to avoid name conflict with texmath 0.6.7
e7d8039Matthew Pickering
src/Text/Pandoc/Readers/TeXMath.hs+3−12
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
27
28Conversion of TeX math to a list of 'Pandoc' inline elements.
28Conversion of TeX math to a list of 'Pandoc' inline elements.
29-}
29-}
30−module Text.Pandoc.Readers.TeXMath ( readTeXMath, readTeXMath' ) where
30+module Text.Pandoc.Readers.TeXMath ( texMathToInlines ) where
31
31
32import Text.Pandoc.Definition
32import Text.Pandoc.Definition
33import Text.TeXMath
33import Text.TeXMath
@@ -35,22 +35,13 @@ import Text.TeXMath
35-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
35-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
36-- Defaults to raw formula between @$@ or @$$@ characters if entire formula
36-- Defaults to raw formula between @$@ or @$$@ characters if entire formula
37-- can't be converted.
37-- can't be converted.
38−readTeXMath' :: MathType
38+texMathToInlines :: MathType
39 -> String -- ^ String to parse (assumes @'\n'@ line endings)
39 -> String -- ^ String to parse (assumes @'\n'@ line endings)
40 -> [Inline]
40 -> [Inline]
41−readTeXMath' mt inp = case texMathToPandoc dt inp of
41+texMathToInlines mt inp = case texMathToPandoc dt inp of
42 Left _ -> [Str (delim ++ inp ++ delim)]
42 Left _ -> [Str (delim ++ inp ++ delim)]
43 Right res -> res
43 Right res -> res
44 where (dt, delim) = case mt of
44 where (dt, delim) = case mt of
45 DisplayMath -> (DisplayBlock, "$$")
45 DisplayMath -> (DisplayBlock, "$$")
46 InlineMath -> (DisplayInline, "$")
46 InlineMath -> (DisplayInline, "$")
47
47
48−{-# DEPRECATED readTeXMath "Use readTeXMath' from Text.Pandoc.JSON instead" #-}
49−-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
50−-- Defaults to raw formula between @$@ characters if entire formula
51−-- can't be converted. (This is provided for backwards compatibility;
52−-- it is better to use @readTeXMath'@, which properly distinguishes
53−-- between display and inline math.)
54−readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings)
55− -> [Inline]
56−readTeXMath = readTeXMath' InlineMath
src/Text/Pandoc/Writers/Docbook.hs+2−2
@@ -299,8 +299,8 @@ inlineToDocbook opts (Math t str)
299 $ fixNS
299 $ fixNS
300 $ removeAttr r
300 $ removeAttr r
301 Left _ -> inlinesToDocbook opts
301 Left _ -> inlinesToDocbook opts
302− $ readTeXMath' t str
302+ $ texMathToInlines t str
303− | otherwise = inlinesToDocbook opts $ readTeXMath' t str
303+ | otherwise = inlinesToDocbook opts $ texMathToInlines t str
304 where (dt, tagtype) = case t of
304 where (dt, tagtype) = case t of
305 InlineMath -> (DisplayInline,"inlineequation")
305 InlineMath -> (DisplayInline,"inlineequation")
306 DisplayMath -> (DisplayBlock,"informalequation")
306 DisplayMath -> (DisplayBlock,"informalequation")
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -756,7 +756,7 @@ inlineToOpenXML opts (Math mathType str) = do
756 else DisplayInline
756 else DisplayInline
757 case texMathToOMML displayType str of
757 case texMathToOMML displayType str of
758 Right r -> return [r]
758 Right r -> return [r]
759− Left _ -> inlinesToOpenXML opts (readTeXMath' mathType str)
759+ Left _ -> inlinesToOpenXML opts (texMathToInlines mathType str)
760inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst
760inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst
761inlineToOpenXML opts (Code attrs str) =
761inlineToOpenXML opts (Code attrs str) =
762 withTextProp (rStyle "VerbatimChar")
762 withTextProp (rStyle "VerbatimChar")
src/Text/Pandoc/Writers/HTML.hs+2−2
@@ -704,14 +704,14 @@ inlineToHtml opts inline =
704 Right r -> return $ preEscapedString $
704 Right r -> return $ preEscapedString $
705 ppcElement conf r
705 ppcElement conf r
706 Left _ -> inlineListToHtml opts
706 Left _ -> inlineListToHtml opts
707− (readTeXMath' t str) >>= return .
707+ (texMathToInlines t str) >>= return .
708 (H.span ! A.class_ "math")
708 (H.span ! A.class_ "math")
709 MathJax _ -> return $ H.span ! A.class_ "math" $ toHtml $
709 MathJax _ -> return $ H.span ! A.class_ "math" $ toHtml $
710 case t of
710 case t of
711 InlineMath -> "\\(" ++ str ++ "\\)"
711 InlineMath -> "\\(" ++ str ++ "\\)"
712 DisplayMath -> "\\[" ++ str ++ "\\]"
712 DisplayMath -> "\\[" ++ str ++ "\\]"
713 PlainMath -> do
713 PlainMath -> do
714− x <- inlineListToHtml opts (readTeXMath' t str)
714+ x <- inlineListToHtml opts (texMathToInlines t str)
715 let m = H.span ! A.class_ "math" $ x
715 let m = H.span ! A.class_ "math" $ x
716 let brtag = if writerHtml5 opts then H5.br else H.br
716 let brtag = if writerHtml5 opts then H5.br else H.br
717 return $ case t of
717 return $ case t of
src/Text/Pandoc/Writers/Haddock.hs+2−2
@@ -39,7 +39,7 @@ import Text.Pandoc.Options
39import Data.List ( intersperse, transpose )
39import Data.List ( intersperse, transpose )
40import Text.Pandoc.Pretty
40import Text.Pandoc.Pretty
41import Control.Monad.State
41import Control.Monad.State
42−import Text.Pandoc.Readers.TeXMath (readTeXMath')
42+import Text.Pandoc.Readers.TeXMath (texMathToInlines)
43import Network.URI (isURI)
43import Network.URI (isURI)
44import Data.Default
44import Data.Default
45
45
@@ -319,7 +319,7 @@ inlineToHaddock opts (Math mt str) = do
319 let adjust x = case mt of
319 let adjust x = case mt of
320 DisplayMath -> cr <> x <> cr
320 DisplayMath -> cr <> x <> cr
321 InlineMath -> x
321 InlineMath -> x
322− adjust `fmap` (inlineListToHaddock opts $ readTeXMath' mt str)
322+ adjust `fmap` (inlineListToHaddock opts $ texMathToInlines mt str)
323inlineToHaddock _ (RawInline f str)
323inlineToHaddock _ (RawInline f str)
324 | f == "haddock" = return $ text str
324 | f == "haddock" = return $ text str
325 | otherwise = return empty
325 | otherwise = return empty
src/Text/Pandoc/Writers/Man.hs+2−2
@@ -331,9 +331,9 @@ inlineToMan _ (Code _ str) =
331 return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]"
331 return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]"
332inlineToMan _ (Str str) = return $ text $ escapeString str
332inlineToMan _ (Str str) = return $ text $ escapeString str
333inlineToMan opts (Math InlineMath str) =
333inlineToMan opts (Math InlineMath str) =
334− inlineListToMan opts $ readTeXMath' InlineMath str
334+ inlineListToMan opts $ texMathToInlines InlineMath str
335inlineToMan opts (Math DisplayMath str) = do
335inlineToMan opts (Math DisplayMath str) = do
336− contents <- inlineListToMan opts $ readTeXMath' DisplayMath str
336+ contents <- inlineListToMan opts $ texMathToInlines DisplayMath str
337 return $ cr <> text ".RS" $$ contents $$ text ".RE"
337 return $ cr <> text ".RS" $$ contents $$ text ".RE"
338inlineToMan _ (RawInline f str)
338inlineToMan _ (RawInline f str)
339 | f == Format "man" = return $ text str
339 | f == Format "man" = return $ text str
src/Text/Pandoc/Writers/Markdown.hs+3−3
@@ -45,7 +45,7 @@ import Text.Pandoc.Pretty
45import Control.Monad.State
45import Control.Monad.State
46import qualified Data.Set as Set
46import qualified Data.Set as Set
47import Text.Pandoc.Writers.HTML (writeHtmlString)
47import Text.Pandoc.Writers.HTML (writeHtmlString)
48−import Text.Pandoc.Readers.TeXMath (readTeXMath')
48+import Text.Pandoc.Readers.TeXMath (texMathToInlines)
49import Text.HTML.TagSoup (parseTags, isTagText, Tag(..))
49import Text.HTML.TagSoup (parseTags, isTagText, Tag(..))
50import Network.URI (isURI)
50import Network.URI (isURI)
51import Data.Default
51import Data.Default
@@ -733,7 +733,7 @@ inlineToMarkdown opts (Math InlineMath str)
733 return $ "\\(" <> text str <> "\\)"
733 return $ "\\(" <> text str <> "\\)"
734 | isEnabled Ext_tex_math_double_backslash opts =
734 | isEnabled Ext_tex_math_double_backslash opts =
735 return $ "\\\\(" <> text str <> "\\\\)"
735 return $ "\\\\(" <> text str <> "\\\\)"
736− | otherwise = inlineListToMarkdown opts $ readTeXMath' InlineMath str
736+ | otherwise = inlineListToMarkdown opts $ texMathToInlines InlineMath str
737inlineToMarkdown opts (Math DisplayMath str)
737inlineToMarkdown opts (Math DisplayMath str)
738 | isEnabled Ext_tex_math_dollars opts =
738 | isEnabled Ext_tex_math_dollars opts =
739 return $ "$$" <> text str <> "$$"
739 return $ "$$" <> text str <> "$$"
@@ -742,7 +742,7 @@ inlineToMarkdown opts (Math DisplayMath str)
742 | isEnabled Ext_tex_math_double_backslash opts =
742 | isEnabled Ext_tex_math_double_backslash opts =
743 return $ "\\\\[" <> text str <> "\\\\]"
743 return $ "\\\\[" <> text str <> "\\\\]"
744 | otherwise = (\x -> cr <> x <> cr) `fmap`
744 | otherwise = (\x -> cr <> x <> cr) `fmap`
745− inlineListToMarkdown opts (readTeXMath' DisplayMath str)
745+ inlineListToMarkdown opts (texMathToInlines DisplayMath str)
746inlineToMarkdown opts (RawInline f str)
746inlineToMarkdown opts (RawInline f str)
747 | f == "html" || f == "markdown" ||
747 | f == "html" || f == "markdown" ||
748 (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) =
748 (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) =
src/Text/Pandoc/Writers/OpenDocument.hs+1−1
@@ -380,7 +380,7 @@ inlineToOpenDocument o ils
380 | SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l
380 | SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l
381 | Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l
381 | Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l
382 | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s
382 | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s
383− | Math t s <- ils = inlinesToOpenDocument o (readTeXMath' t s)
383+ | Math t s <- ils = inlinesToOpenDocument o (texMathToInlines t s)
384 | Cite _ l <- ils = inlinesToOpenDocument o l
384 | Cite _ l <- ils = inlinesToOpenDocument o l
385 | RawInline f s <- ils = if f == Format "opendocument"
385 | RawInline f s <- ils = if f == Format "opendocument"
386 then return $ text s
386 then return $ text s
src/Text/Pandoc/Writers/RTF.hs+1−1
@@ -332,7 +332,7 @@ inlineToRTF (Quoted DoubleQuote lst) =
332 "\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\""
332 "\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\""
333inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
333inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
334inlineToRTF (Str str) = stringToRTF str
334inlineToRTF (Str str) = stringToRTF str
335−inlineToRTF (Math t str) = inlineListToRTF $ readTeXMath' t str
335+inlineToRTF (Math t str) = inlineListToRTF $ texMathToInlines t str
336inlineToRTF (Cite _ lst) = inlineListToRTF lst
336inlineToRTF (Cite _ lst) = inlineListToRTF lst
337inlineToRTF (RawInline f str)
337inlineToRTF (RawInline f str)
338 | f == Format "rtf" = str
338 | f == Format "rtf" = str