From 313405f59aa09b6f1a027002d35bc75cb15c976e Mon Sep 17 00:00:00 2001 From: fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> Date: Thu, 25 Jun 2009 02:01:41 +0000 Subject: Allow continuation lines in line blocks. Also added test cases for line blocks for RST reader. Resolves Issue #149. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1583 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/RST.hs | 9 +++++---- tests/rst-reader.native | 5 ++++- tests/rst-reader.rst | 13 +++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index ae025f4ea..4fe6ada5e 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -125,8 +125,8 @@ block = choice [ codeBlock , unknownDirective , header , hrule + , lineBlock -- must go before definitionList , list - , lineBlock , lhsCodeBlock , para , plain @@ -183,14 +183,15 @@ lineBlockLine :: GenParser Char ParserState [Inline] lineBlockLine = try $ do string "| " white <- many (oneOf " \t") - line <- manyTill inline newline - return $ (if null white then [] else [Str white]) ++ line ++ [LineBreak] + line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ') + optional endline + return $ normalizeSpaces $ (if null white then [] else [Str white]) ++ line lineBlock :: GenParser Char ParserState Block lineBlock = try $ do lines' <- many1 lineBlockLine blanklines - return $ Para (concat lines') + return $ Para (intercalate [LineBreak] lines') -- -- paragraph block diff --git a/tests/rst-reader.native b/tests/rst-reader.native index e0cedd59c..88a036ebc 100644 --- a/tests/rst-reader.native +++ b/tests/rst-reader.native @@ -234,5 +234,8 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str , Header 1 [Str "Comments"] , Para [Str "First",Space,Str "paragraph"] , Para [Str "Another",Space,Str "paragraph"] -, Para [Str "A",Space,Str "third",Space,Str "paragraph"] ] +, Para [Str "A",Space,Str "third",Space,Str "paragraph"] +, Header 1 [Str "Line",Space,Str "blocks"] +, Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str " ",Str "or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str " ",Str "when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str " ",Str "due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"] +, Para [Str "Continuation",Space,Str "line",LineBreak,Str " ",Str "and",Space,Str "another"] ] diff --git a/tests/rst-reader.rst b/tests/rst-reader.rst index 09ff2b75c..2fcb4a5b9 100644 --- a/tests/rst-reader.rst +++ b/tests/rst-reader.rst @@ -428,3 +428,16 @@ Another paragraph A third paragraph +Line blocks +=========== + +| But can a bee be said to be +| or not to be an entire bee, +| when half the bee is not a bee, +| due to some ancient injury? + +| Continuation + line +| and + another + -- cgit v1.2.3