From 5c029594835c531a3c66aad2b51872ec1f04541c Mon Sep 17 00:00:00 2001
From: fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>
Date: Sat, 6 Sep 2008 21:24:33 +0000
Subject: [PATCH] LaTeX reader: Refactored math parsers, limited support for
 eqnarray.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1426 788f1e2b-df1e-0410-8736-df70ead52e1b
---
 Text/Pandoc/Readers/LaTeX.hs | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Text/Pandoc/Readers/LaTeX.hs b/Text/Pandoc/Readers/LaTeX.hs
index e1efce1e9..d2dff2d5a 100644
--- a/Text/Pandoc/Readers/LaTeX.hs
+++ b/Text/Pandoc/Readers/LaTeX.hs
@@ -687,13 +687,20 @@ math3 :: GenParser Char st String
 math3 = try $ char '$' >> math1 >>~ char '$'
 
 math4 :: GenParser Char st String
-math4 = try $ (begin "equation") >> spaces >> manyTill anyChar (end "equation")
+math4 = try $ do
+  name <- begin "equation" <|> begin "equation*" <|> begin "displaymath" <|> begin "displaymath*"
+  spaces
+  manyTill anyChar (end name)
 
 math5 :: GenParser Char st String
-math5 = try $ (begin "displaymath") >> spaces >> manyTill anyChar (end "displaymath")
+math5 = try $ (string "\\[") >> spaces >> manyTill anyChar (try $ string "\\]")
 
 math6 :: GenParser Char st String
-math6 = try $ (string "\\[") >> spaces >> manyTill anyChar (try $ string "\\]")
+math6 = try $ do
+  name <- begin "eqnarray" <|> begin "eqnarray*"
+  spaces
+  res <- manyTill anyChar (end name)
+  return $ filter (/= '&') res  -- remove eqnarray alignment codes
 
 --
 -- links and images