Skip to content

Commit

Permalink
Merge pull request #1239 from tarleb/org-linebreak
Browse files Browse the repository at this point in the history
Org linebreaks
  • Loading branch information
jgm committed Apr 13, 2014
2 parents d5d4227 + 67051b6 commit 86b4da9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Expand Up @@ -10,3 +10,7 @@ trim_trailing_whitespace = true

[*.{markdown,md}]
trim_trailing_whitespace = false

[tests/*]
insert_final_newline = false
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions src/Text/Pandoc/Readers/Org.hs
Expand Up @@ -539,6 +539,7 @@ anyLineNewline = (++ "\n") <$> anyLine
inline :: OrgParser Inlines
inline =
choice [ whitespace
, linebreak
, link
, str
, endline
Expand Down Expand Up @@ -570,6 +571,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
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Writers/Org.hs
Expand Up @@ -271,7 +271,7 @@ inlineToOrg (Math t str) = do
else "$$" <> text str <> "$$"
inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str
inlineToOrg (RawInline _ _) = return empty
inlineToOrg (LineBreak) = return cr -- there's no line break in Org
inlineToOrg (LineBreak) = return (text "\\\\" <> cr)
inlineToOrg Space = return space
inlineToOrg (Link txt (src, _)) = do
case txt of
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
2 changes: 1 addition & 1 deletion tests/writer.org
Expand Up @@ -42,7 +42,7 @@ item.

Here's one with a bullet. * criminey.

There should be a hard line break
There should be a hard line break\\
here.

--------------
Expand Down

0 comments on commit 86b4da9

Please sign in to comment.