summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-04-13 14:04:48 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-04-13 14:04:48 -0700
commit86b4da9dec0f42f2571bb249a082f9ac41fe568d (patch)
tree630e9c83e3c2cc7d4492bdae40b5c792373e2897
parentd5d4227ea5144d7c9da2ffdd44fbbd8131d4d86d (diff)
parent67051b6e5d07f30b1a3c60231fc8561ec6a1bc86 (diff)
Merge pull request #1239 from tarleb/org-linebreak
Org linebreaks
-rw-r--r--.editorconfig4
-rw-r--r--src/Text/Pandoc/Readers/Org.hs4
-rw-r--r--src/Text/Pandoc/Writers/Org.hs2
-rw-r--r--tests/Tests/Readers/Org.hs4
-rw-r--r--tests/writer.org2
5 files changed, 14 insertions, 2 deletions
diff --git a/.editorconfig b/.editorconfig
index 9c562bd1f..5f40572b0 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -10,3 +10,7 @@ trim_trailing_whitespace = true
[*.{markdown,md}]
trim_trailing_whitespace = false
+
+[tests/*]
+insert_final_newline = false
+trim_trailing_whitespace = false
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 901a49fc8..bda0b0262 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -539,6 +539,7 @@ anyLineNewline = (++ "\n") <$> anyLine
inline :: OrgParser Inlines
inline =
choice [ whitespace
+ , linebreak
, link
, str
, endline
@@ -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
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
index d318c5f6a..58a5729e7 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -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
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index 99dadc0ac..f39bd7992 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -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*"
diff --git a/tests/writer.org b/tests/writer.org
index 85016f352..524d49305 100644
--- a/tests/writer.org
+++ b/tests/writer.org
@@ -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.
--------------