git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Fixed bug with whitespace at beginning of file.

Previously a file beginning " hi" would cause a parse error. Also cleaned up comment parsing.

commit71ca44db6e8893b0394e6cd38c637deee0524371 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 30 Jan 2011, 08:21 (16 years ago) parent2a9f55c
2 files changed+11−2
src/Tests/Readers/LaTeX.hs+9 src/Text/Pandoc/Readers/LaTeX.hs+2−2
src/Tests/Readers/LaTeX.hs+9
@@ -41,6 +41,15 @@ tests = [ testGroup "basic"
4141 header 1 ("text" +++ space +++ link "/url" "" "link")
4242 ]
4343
44+ , testGroup "space and comments"
45+ [ "blank lines + space at beginning" =:
46+ "\n \n hi" =?> para "hi"
47+ , "blank lines + space + comments" =:
48+ "% my comment\n\n \n % another\n\nhi" =?> para "hi"
49+ , "comment in paragraph" =:
50+ "hi % this is a comment\nthere\n" =?> para "hi there"
51+ ]
52+
4453 , testGroup "citations"
4554 [ natbibCitations
4655 , biblatexCitations
src/Text/Pandoc/Readers/LaTeX.hs+2−2
@@ -136,8 +136,8 @@ processLaTeXPreamble = do
136136-- | Parse LaTeX and return 'Pandoc'.
137137parseLaTeX :: GenParser Char ParserState Pandoc
138138parseLaTeX = do
139− skipMany $ spaces >> comment
140139 spaces
140+ skipMany $ comment >> spaces
141141 blocks <- try (processLaTeXPreamble >> environment "document")
142142 <|> (many block >>~ (spaces >> eof))
143143 state <- getState
@@ -528,7 +528,7 @@ skipChar = do
528528 return Null
529529
530530commentBlock :: GenParser Char st Block
531−commentBlock = comment >> return Null
531+commentBlock = many1 (comment >> spaces) >> return Null
532532
533533--
534534-- inline