git.iko.soy/typeable/pandoc
on master help sign in
Fixed parsing of RST comment blocks.

Modified 'unknown directive' in RST reader. Added RST reader tests for comment blocks. Resolves Issue #86 and Debian Bug#500662. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1484 788f1e2b-df1e-0410-8736-df70ead52e1b

commit22549e19c6017f6b34692c3cc0eb994e4790709b authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 6 Nov 2008, 16:49 (18 years ago) parentf0e7d25
3 files changed+36−5
Text/Pandoc/Readers/RST.hs+5−4 tests/rst-reader.native+5−1 tests/rst-reader.rst+26
Text/Pandoc/Readers/RST.hs+5−4
@@ -367,6 +367,8 @@ list = choice [ bulletList, orderedList, definitionList ] <?> "list"
367367
368368definitionListItem :: GenParser Char ParserState ([Inline], [Block])
369369definitionListItem = try $ do
370+ -- avoid capturing a directive or comment
371+ notFollowedBy (try $ char '.' >> char '.')
370372 term <- many1Till inline endline
371373 raw <- indentedBlock
372374 -- parse the extracted block, which may contain various block elements:
@@ -464,11 +466,10 @@ bulletList = many1 (listItem bulletListStart) >>=
464466
465467unknownDirective :: GenParser Char st Block
466468unknownDirective = try $ do
467− string ".. "
469+ string ".."
470+ notFollowedBy (noneOf " \t\n")
468471 manyTill anyChar newline
469− many (string " :" >> many1 (noneOf "\n:") >> char ':' >>
470− many1 (noneOf "\n") >> newline)
471− optional blanklines
472+ many $ blanklines <|> (oneOf " \t" >> manyTill anyChar newline)
472473 return Null
473474
474475--
tests/rst-reader.native+5−1
@@ -230,5 +230,9 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
230230, Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902)",Str ":"]
231231, Plain [Image [Str "image"] ("lalune.jpg","")]
232232, Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","Voyage dans la Lune")]
233−, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."] ]
233+, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
234+, Header 1 [Str "Comments"]
235+, Para [Str "First",Space,Str "paragraph"]
236+, Para [Str "Another",Space,Str "paragraph"]
237+, Para [Str "A",Space,Str "third",Space,Str "paragraph"] ]
234238
tests/rst-reader.rst+26
@@ -402,3 +402,29 @@ From "Voyage dans la Lune" by Georges Melies (1902):
402402Here is a movie |movie| icon.
403403
404404.. |movie| image:: movie.jpg
405+
406+Comments
407+========
408+
409+First paragraph
410+
411+.. comment
412+
413+..
414+ Comment block, should not appear in output
415+ as defined by reStructuredText
416+
417+Another paragraph
418+
419+..
420+ Another comment block.
421+
422+ This one spans several
423+ text elements.
424+
425+ It doesn't end until
426+ indentation is restored to the
427+ preceding level.
428+
429+A third paragraph
430+