git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1239 from tarleb/org-linebreak

Org linebreaks

commit86b4da9dec0f42f2571bb249a082f9ac41fe568d authorJohn MacFarlane <jgm@berkeley.edu> dateSun 13 Apr 2014, 14:04 (13 years ago) parentd5d422767051b6
5 files changed+14−2
.editorconfig+4 src/Text/Pandoc/Readers/Org.hs+4 src/Text/Pandoc/Writers/Org.hs+1−1 tests/Tests/Readers/Org.hs+4 tests/writer.org+1−1
.editorconfig+4
@@ -10,3 +10,7 @@ trim_trailing_whitespace = true
1010
1111[*.{markdown,md}]
1212trim_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
539539inline :: OrgParser Inlines
540540inline =
541541 choice [ whitespace
542+ , linebreak
542543 , link
543544 , str
544545 , endline
@@ -570,6 +571,9 @@ whitespace = B.space <$ skipMany1 spaceChar
570571 <* updateLastForbiddenCharPos
571572 <?> "whitespace"
572573
574+linebreak :: OrgParser Inlines
575+linebreak = try $ B.linebreak <$ string "\\\\" <* skipSpaces <* newline
576+
573577str :: OrgParser Inlines
574578str = B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")
575579 <* updateLastStrPos
src/Text/Pandoc/Writers/Org.hs+1−1
@@ -271,7 +271,7 @@ inlineToOrg (Math t str) = do
271271 else "$$" <> text str <> "$$"
272272inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str
273273inlineToOrg (RawInline _ _) = return empty
274−inlineToOrg (LineBreak) = return cr -- there's no line break in Org
274+inlineToOrg (LineBreak) = return (text "\\\\" <> cr)
275275inlineToOrg Space = return space
276276inlineToOrg (Link txt (src, _)) = do
277277 case txt of
tests/Tests/Readers/Org.hs+4
@@ -94,6 +94,10 @@ tests =
9494 "a_{n+1}" =?>
9595 para (str "a" <> subscript "n+1")
9696
97+ , "Linebreak" =:
98+ "line \\\\ \nbreak" =?>
99+ para ("line" <> linebreak <> "break")
100+
97101 , "Markup-chars not occuring on word break are symbols" =:
98102 unlines [ "this+that+ +so+on"
99103 , "seven*eight* nine*"
tests/writer.org+1−1
@@ -42,7 +42,7 @@ item.
4242
4343Here's one with a bullet. * criminey.
4444
45−There should be a hard line break
45+There should be a hard line break\\
4646here.
4747
4848--------------