Muse reader: fix parsing of trailing whitespace

Newline after whitespace now results in softbreak
instead of space.
This commit is contained in:
Alexander Krotov 2018-01-28 02:59:06 +03:00
parent 75762ee0dc
commit 248f6076bc
2 changed files with 7 additions and 8 deletions

View file

@ -592,7 +592,7 @@ inlineList = [ whitespace
]
inline :: PandocMonad m => MuseParser m (F Inlines)
inline = choice [endline, linebreak] <|> choice inlineList <?> "inline"
inline = endline <|> choice inlineList <?> "inline"
endline :: PandocMonad m => MuseParser m (F Inlines)
endline = try $ do
@ -626,13 +626,6 @@ footnote = try $ do
let contents' = runF contents st { stateNotes' = M.empty }
return $ B.note contents'
linebreak :: PandocMonad m => MuseParser m (F Inlines)
linebreak = try $ do
skipMany spaceChar
newline
notFollowedBy newline
return $ return B.space
whitespace :: PandocMonad m => MuseParser m (F Inlines)
whitespace = try $ do
skipMany1 spaceChar

View file

@ -119,6 +119,12 @@ tests =
, "Linebreak" =: "Line <br> break" =?> para ("Line" <> linebreak <> "break")
, "Trailing whitespace inside paragraph" =:
T.unlines [ "First line " -- trailing whitespace here
, "second line"
]
=?> para "First line\nsecond line"
, "Non-breaking space" =: "Foo~~bar" =?> para "Foo\160bar"
, "Single ~" =: "Foo~bar" =?> para "Foo~bar"