diff options
| author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-08-13 03:02:42 +0000 |
|---|---|---|
| committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-08-13 03:02:42 +0000 |
| commit | f53fb554fe0acf88d7c697236bbd1373e78f3d83 (patch) | |
| tree | 31f3a3e7b5274458a0738482a32c4b881da2e180 /Text/Pandoc/Readers | |
| parent | aeaf5e5108de4e7ab20782cf753e4617df45d8a2 (diff) | |
| download | pandoc-f53fb554fe0acf88d7c697236bbd1373e78f3d83.tar.gz | |
Support for display math; changed ASCIIMathML -> LaTeXMathML:
Resolves Issue #47.
+ Added a DisplayMath/InlineMath selector to Math inlines.
+ Markdown parser yields DisplayMath for $$...$$.
+ LaTeX parser yields DisplayMath when appropriate. Removed
mathBlock parsers, since the same effect is achieved by the math
inline parsers, now that they handle display math.
+ Writers handle DisplayMath as appropriate for the format.
+ Changed -m option to use LaTeXMathML rather than ASCIIMathML.
LaTeXMathML is closer to LaTeX in its display of math, and
supports many non-math LaTeX environments.
+ Modified HTML writer to print raw TeX when LaTeXMathML is
being used instead of suppressing it.
+ Removed ASCIIMathML files from data/ and added LaTeXMathML.
+ Replaced ASCIIMathML with LaTeXMathML in source files.
+ Modified README and pandoc man page source.
+ Modified web page.
+ Added --latexmathml option (kept --asciimathml as a synonym
for backwards compatibility)
+ Modified tests accordingly; added new tests for display math.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1409 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc/Readers')
| -rw-r--r-- | Text/Pandoc/Readers/LaTeX.hs | 61 | ||||
| -rw-r--r-- | Text/Pandoc/Readers/Markdown.hs | 11 |
2 files changed, 34 insertions, 38 deletions
diff --git a/Text/Pandoc/Readers/LaTeX.hs b/Text/Pandoc/Readers/LaTeX.hs index 2ce0204ee..883c1bbd1 100644 --- a/Text/Pandoc/Readers/LaTeX.hs +++ b/Text/Pandoc/Readers/LaTeX.hs @@ -153,7 +153,6 @@ block = choice [ hrule , header , list , blockQuote - , mathBlock , comment , bibliographic , para @@ -219,26 +218,6 @@ blockQuote = (environment "quote" <|> environment "quotation") >>~ spaces >>= return . BlockQuote -- --- math block --- - -mathBlock :: GenParser Char st Block -mathBlock = mathBlockWith (begin "equation") (end "equation") <|> - mathBlockWith (begin "displaymath") (end "displaymath") <|> - mathBlockWith (try $ string "\\[") (try $ string "\\]") <?> - "math block" - -mathBlockWith :: GenParser Char st t - -> GenParser Char st end - -> GenParser Char st Block -mathBlockWith start end' = try $ do - start - spaces - result <- manyTill anyChar end' - spaces - return $ BlockQuote [Para [Math result]] - --- -- list blocks -- @@ -683,21 +662,31 @@ endline = try $ newline >> notFollowedBy blankline >> return Space -- math math :: GenParser Char st Inline -math = math1 <|> math2 <?> "math" - -math1 :: GenParser Char st Inline -math1 = try $ do - char '$' - result <- many (noneOf "$") - char '$' - return $ Math result - -math2 :: GenParser Char st Inline -math2 = try $ do - string "\\(" - result <- many (noneOf "$") - string "\\)" - return $ Math result +math = (math3 >>= return . Math DisplayMath) + <|> (math1 >>= return . Math InlineMath) + <|> (math2 >>= return . Math InlineMath) + <|> (math4 >>= return . Math DisplayMath) + <|> (math5 >>= return . Math DisplayMath) + <|> (math6 >>= return . Math DisplayMath) + <?> "math" + +math1 :: GenParser Char st String +math1 = try $ char '$' >> manyTill anyChar (char '$') + +math2 :: GenParser Char st String +math2 = try $ string "\\(" >> manyTill anyChar (try $ string "\\)") + +math3 :: GenParser Char st String +math3 = try $ char '$' >> math1 >>~ char '$' + +math4 :: GenParser Char st String +math4 = try $ (begin "equation") >> spaces >> manyTill anyChar (end "equation") + +math5 :: GenParser Char st String +math5 = try $ (begin "displaymath") >> spaces >> manyTill anyChar (end "displaymath") + +math6 :: GenParser Char st String +math6 = try $ (string "\\[") >> spaces >> manyTill anyChar (try $ string "\\]") -- -- links and images diff --git a/Text/Pandoc/Readers/Markdown.hs b/Text/Pandoc/Readers/Markdown.hs index ac7096d37..f030f07ad 100644 --- a/Text/Pandoc/Readers/Markdown.hs +++ b/Text/Pandoc/Readers/Markdown.hs @@ -870,14 +870,21 @@ mathWord = many1 ((noneOf " \t\n\\$") <|> (try (char '\\') >>~ notFollowedBy (char '$'))) math :: GenParser Char ParserState Inline -math = try $ do +math = (mathDisplay >>= return . Math DisplayMath) + <|> (mathInline >>= return . Math InlineMath) + +mathDisplay :: GenParser Char ParserState String +mathDisplay = try $ char '$' >> mathInline >>~ char '$' >>~ notFollowedBy digit + +mathInline :: GenParser Char ParserState String +mathInline = try $ do failIfStrict char '$' notFollowedBy space words' <- sepBy1 mathWord (many1 (spaceChar <|> (newline >>~ notFollowedBy' blankline))) char '$' notFollowedBy digit - return $ Math $ joinWithSep " " words' + return $ joinWithSep " " words' emph :: GenParser Char ParserState Inline emph = ((enclosed (char '*') (notFollowedBy' strong >> char '*') inline) <|> |
