git.iko.soy/typeable/pandoc
on master help sign in
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

commit313405f59aa09b6f1a027002d35bc75cb15c976e authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 25 Jun 2009, 02:01 (17 years ago) parent15258f6
3 files changed+22−5
src/Text/Pandoc/Readers/RST.hs+5−4 tests/rst-reader.native+4−1 tests/rst-reader.rst+13
src/Text/Pandoc/Readers/RST.hs+5−4
@@ -125,8 +125,8 @@ block = choice [ codeBlock
125125 , unknownDirective
126126 , header
127127 , hrule
128+ , lineBlock -- must go before definitionList
128129 , list
129− , lineBlock
130130 , lhsCodeBlock
131131 , para
132132 , plain
@@ -183,14 +183,15 @@ lineBlockLine :: GenParser Char ParserState [Inline]
183183lineBlockLine = try $ do
184184 string "| "
185185 white <- many (oneOf " \t")
186− line <- manyTill inline newline
187− return $ (if null white then [] else [Str white]) ++ line ++ [LineBreak]
186+ line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ')
187+ optional endline
188+ return $ normalizeSpaces $ (if null white then [] else [Str white]) ++ line
188189
189190lineBlock :: GenParser Char ParserState Block
190191lineBlock = try $ do
191192 lines' <- many1 lineBlockLine
192193 blanklines
193− return $ Para (concat lines')
194+ return $ Para (intercalate [LineBreak] lines')
194195
195196--
196197-- paragraph block
tests/rst-reader.native+4−1
@@ -234,5 +234,8 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
234234, Header 1 [Str "Comments"]
235235, Para [Str "First",Space,Str "paragraph"]
236236, Para [Str "Another",Space,Str "paragraph"]
237−, Para [Str "A",Space,Str "third",Space,Str "paragraph"] ]
237+, Para [Str "A",Space,Str "third",Space,Str "paragraph"]
238+, Header 1 [Str "Line",Space,Str "blocks"]
239+, 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?"]
240+, Para [Str "Continuation",Space,Str "line",LineBreak,Str " ",Str "and",Space,Str "another"] ]
238241
tests/rst-reader.rst+13
@@ -428,3 +428,16 @@ Another paragraph
428428
429429A third paragraph
430430
431+Line blocks
432+===========
433+
434+| But can a bee be said to be
435+| or not to be an entire bee,
436+| when half the bee is not a bee,
437+| due to some ancient injury?
438+
439+| Continuation
440+ line
441+| and
442+ another
443+