aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/RST.hs11
-rw-r--r--tests/Tests/Readers/RST.hs4
-rw-r--r--tests/rst-reader.native4
-rw-r--r--tests/rst-reader.rst2
4 files changed, 13 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index cc8293132..5f6850148 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -206,16 +206,21 @@ lineBlockLine = try $ do
char '|'
char ' ' <|> lookAhead (char '\n')
white <- many spaceChar
- line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ')
+ line <- many1 $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ')
optional endline
return $ if null white
then mconcat line
- else B.str white <> mconcat line
+ else B.str (spToNbsp white) <> mconcat line
+
+spToNbsp :: String -> String
+spToNbsp (' ':xs) = '\160' : spToNbsp xs
+spToNbsp (x:xs) = x : spToNbsp xs
+spToNbsp [] = ""
lineBlock :: RSTParser Blocks
lineBlock = try $ do
lines' <- many1 lineBlockLine
- blanklines
+ skipMany1 $ blankline <|> try (char '|' >> blankline)
return $ B.para (mconcat $ intersperse B.linebreak lines')
--
diff --git a/tests/Tests/Readers/RST.hs b/tests/Tests/Readers/RST.hs
index fdce7c8f6..0ad21f224 100644
--- a/tests/Tests/Readers/RST.hs
+++ b/tests/Tests/Readers/RST.hs
@@ -18,8 +18,8 @@ infix 4 =:
tests :: [Test]
tests = [ "line block with blank line" =:
- "| a\n|\n| b" =?> para (str "a" <> linebreak <>
- linebreak <> str " " <> str "b")
+ "| a\n|\n| b" =?> para (str "a") <>
+ para (str "\160b")
, "field list" =:
[_LIT|
:Hostname: media08
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index e4419dd13..895d06d69 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -232,8 +232,8 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
,Para [Str "Another",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 " or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,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 " due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
-,Para [Str "Continuation",Space,Str "line",LineBreak,Str " and",Space,Str "another"]
+,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 "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
+,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]
,Header 1 ("",[],[]) [Str "Simple",Space,Str "Tables"]
,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
[[Plain [Str "col",Space,Str "1"]]
diff --git a/tests/rst-reader.rst b/tests/rst-reader.rst
index 14f57da18..970ab4d4a 100644
--- a/tests/rst-reader.rst
+++ b/tests/rst-reader.rst
@@ -454,7 +454,7 @@ Line blocks
| or not to be an entire bee,
| when half the bee is not a bee,
| due to some ancient injury?
-
+|
| Continuation
line
| and