git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1239 from tarleb/org-linebreak
86b4da9John MacFarlane
.editorconfig+4
@@ -10,3 +10,7 @@ trim_trailing_whitespace = true
10
10
11[*.{markdown,md}]
11[*.{markdown,md}]
12trim_trailing_whitespace = false
12trim_trailing_whitespace = false
13+
14+[tests/*]
15+insert_final_newline = false
16+trim_trailing_whitespace = false
src/Text/Pandoc/Readers/Org.hs+4
@@ -539,6 +539,7 @@ anyLineNewline = (++ "\n") <$> anyLine
539inline :: OrgParser Inlines
539inline :: OrgParser Inlines
540inline =
540inline =
541 choice [ whitespace
541 choice [ whitespace
542+ , linebreak
542 , link
543 , link
543 , str
544 , str
544 , endline
545 , endline
@@ -570,6 +571,9 @@ whitespace = B.space <$ skipMany1 spaceChar
570 <* updateLastForbiddenCharPos
571 <* updateLastForbiddenCharPos
571 <?> "whitespace"
572 <?> "whitespace"
572
573
574+linebreak :: OrgParser Inlines
575+linebreak = try $ B.linebreak <$ string "\\\\" <* skipSpaces <* newline
576+
573str :: OrgParser Inlines
577str :: OrgParser Inlines
574str = B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")
578str = B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")
575 <* updateLastStrPos
579 <* updateLastStrPos
src/Text/Pandoc/Writers/Org.hs+1−1
@@ -271,7 +271,7 @@ inlineToOrg (Math t str) = do
271 else "$$" <> text str <> "$$"
271 else "$$" <> text str <> "$$"
272inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str
272inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str
273inlineToOrg (RawInline _ _) = return empty
273inlineToOrg (RawInline _ _) = return empty
274−inlineToOrg (LineBreak) = return cr -- there's no line break in Org
274+inlineToOrg (LineBreak) = return (text "\\\\" <> cr)
275inlineToOrg Space = return space
275inlineToOrg Space = return space
276inlineToOrg (Link txt (src, _)) = do
276inlineToOrg (Link txt (src, _)) = do
277 case txt of
277 case txt of
tests/Tests/Readers/Org.hs+4
@@ -94,6 +94,10 @@ tests =
94 "a_{n+1}" =?>
94 "a_{n+1}" =?>
95 para (str "a" <> subscript "n+1")
95 para (str "a" <> subscript "n+1")
96
96
97+ , "Linebreak" =:
98+ "line \\\\ \nbreak" =?>
99+ para ("line" <> linebreak <> "break")
100+
97 , "Markup-chars not occuring on word break are symbols" =:
101 , "Markup-chars not occuring on word break are symbols" =:
98 unlines [ "this+that+ +so+on"
102 unlines [ "this+that+ +so+on"
99 , "seven*eight* nine*"
103 , "seven*eight* nine*"
tests/writer.org+1−1
@@ -42,7 +42,7 @@ item.
42
42
43Here's one with a bullet. * criminey.
43Here's one with a bullet. * criminey.
44
44
45−There should be a hard line break
45+There should be a hard line break\\
46here.
46here.
47
47
48--------------
48--------------