Skip to content

Commit

Permalink
Org reader: Read linebreaks
Browse files Browse the repository at this point in the history
Linebreaks are marked by the string `\\` at the end of a line.
  • Loading branch information
tarleb committed Apr 12, 2014
1 parent 3606669 commit 82d4160
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Text/Pandoc/Readers/Org.hs
Expand Up @@ -506,6 +506,7 @@ anyLineNewline = (++ "\n") <$> anyLine
inline :: OrgParser Inlines
inline =
choice [ whitespace
, linebreak
, link
, str
, endline
Expand Down Expand Up @@ -535,6 +536,9 @@ whitespace = B.space <$ skipMany1 spaceChar
<* updateLastForbiddenCharPos
<?> "whitespace"

linebreak :: OrgParser Inlines
linebreak = try $ B.linebreak <$ string "\\\\" <* skipSpaces <* newline

str :: OrgParser Inlines
str = B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")
<* updateLastStrPos
Expand Down
4 changes: 4 additions & 0 deletions tests/Tests/Readers/Org.hs
Expand Up @@ -94,6 +94,10 @@ tests =
"a_{n+1}" =?>
para (str "a" <> subscript "n+1")

, "Linebreak" =:
"line \\\\ \nbreak" =?>
para ("line" <> linebreak <> "break")

, "Markup-chars not occuring on word break are symbols" =:
unlines [ "this+that+ +so+on"
, "seven*eight* nine*"
Expand Down

0 comments on commit 82d4160

Please sign in to comment.