From 1e772aa59c85fb94fe59a287c11d7c4a85b1c579 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 4 Feb 2012 12:51:27 -0800 Subject: LaTeX reader: small bug fixes. --- src/Text/Pandoc/Readers/LaTeX.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 79819e249..d74bfe983 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -139,8 +139,10 @@ double_quote = (doubleQuoted . mconcat) <$> (try $ string "``" *> manyTill inline (try $ string "''")) single_quote :: LP Inlines -single_quote = (singleQuoted . mconcat) <$> - (try $ char '`' *> manyTill inline (try $ char '\'' >> notFollowedBy letter)) +single_quote = char '`' *> + ( try ((singleQuoted . mconcat) <$> + manyTill inline (try $ char '\'' >> notFollowedBy letter)) + <|> lit "`") inline :: LP Inlines inline = (mempty <$ comment) @@ -161,7 +163,8 @@ inline = (mempty <$ comment) <|> (failUnlessLHS *> char '|' *> doLHSverb) <|> (str <$> count 1 tildeEscape) <|> (str <$> string "]") - <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters + <|> (str <$> string "#") -- TODO print warning? + -- <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters inlines :: LP Inlines inlines = mconcat <$> many (notFollowedBy (char '}') *> inline) @@ -174,6 +177,7 @@ block = (mempty <$ comment) <|> blockCommand <|> grouped block <|> paragraph + <|> (mempty <$ char '&') -- loose & in table environment blocks :: LP Blocks @@ -790,23 +794,21 @@ parseTableRow cols = try $ do guard $ length cells' == cols spaces optional $ controlSeq "\\" + spaces return cells' -parseTableHeader :: Int -- ^ number of columns - -> LP [Blocks] -parseTableHeader cols = try $ parseTableRow cols <* hline - simpTable :: LP Blocks simpTable = try $ do spaces aligns <- parseAligns let cols = length aligns optional hline - header' <- option [] $ parseTableHeader cols + header' <- option [] $ try (parseTableRow cols <* hline) rows <- many (parseTableRow cols <* optional hline) spaces let header'' = if null header' then replicate cols mempty else header' + lookAhead $ controlSeq "end" -- make sure we're at end return $ table mempty (zip aligns (repeat 0)) header'' rows -- cgit v1.2.3