diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-10-02 23:11:58 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-10-02 23:11:58 +0200 |
commit | 514662e544a828e6c3904d2fec0216dc19bbcb9f (patch) | |
tree | 9cae897fbdb1b24b94dca8d729cdf8ad07a01fb0 | |
parent | 3e77ea4792979879a80e67f20712766e4af2fdf5 (diff) | |
download | pandoc-514662e544a828e6c3904d2fec0216dc19bbcb9f.tar.gz |
Org reader: support `\n` export option
The `\n` export option turns all newlines in the text into hard
linebreaks.
Closes #3950
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ExportSettings.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Inlines.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ParserState.hs | 2 | ||||
-rw-r--r-- | test/Tests/Readers/Org.hs | 7 |
4 files changed, 12 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs index 11f0972d5..36258aeba 100644 --- a/src/Text/Pandoc/Readers/Org/ExportSettings.hs +++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs @@ -52,7 +52,7 @@ exportSetting = choice , booleanSetting "-" (\val es -> es { exportSpecialStrings = val }) , ignoredSetting ":" , ignoredSetting "<" - , ignoredSetting "\\n" + , booleanSetting "\\n" (\val es -> es { exportPreserveBreaks = val }) , archivedTreeSetting "arch" (\val es -> es { exportArchivedTrees = val }) , booleanSetting "author" (\val es -> es { exportWithAuthor = val }) , ignoredSetting "c" diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs index c5b1ccc52..39f4dc926 100644 --- a/src/Text/Pandoc/Readers/Org/Inlines.hs +++ b/src/Text/Pandoc/Readers/Org/Inlines.hs @@ -158,7 +158,8 @@ endline = try $ do decEmphasisNewlinesCount guard =<< newlinesCountWithinLimits updateLastPreCharPos - returnF B.softbreak + useHardBreaks <- exportPreserveBreaks . orgStateExportSettings <$> getState + returnF (if useHardBreaks then B.linebreak else B.softbreak) -- diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs index fc98213fb..0349f7617 100644 --- a/src/Text/Pandoc/Readers/Org/ParserState.hs +++ b/src/Text/Pandoc/Readers/Org/ParserState.hs @@ -242,6 +242,7 @@ data ExportSettings = ExportSettings , exportEmphasizedText :: Bool -- ^ Parse emphasized text , exportHeadlineLevels :: Int -- ^ Maximum depth of headlines, deeper headlines are convert to list + , exportPreserveBreaks :: Bool -- ^ Whether to preserve linebreaks , exportSmartQuotes :: Bool -- ^ Parse quotes smartly , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts @@ -261,6 +262,7 @@ defaultExportSettings = ExportSettings , exportDrawers = Left ["LOGBOOK"] , exportEmphasizedText = True , exportHeadlineLevels = 3 + , exportPreserveBreaks = False , exportSmartQuotes = False , exportSpecialStrings = True , exportSubSuperscripts = True diff --git a/test/Tests/Readers/Org.hs b/test/Tests/Readers/Org.hs index 0a91d9357..b714c0792 100644 --- a/test/Tests/Readers/Org.hs +++ b/test/Tests/Readers/Org.hs @@ -773,6 +773,13 @@ tests = , para "top-level section 2" ] ] + , "preserve linebreaks as hard breaks" =: + T.unlines [ "#+OPTIONS: \\n:t" + , "first" + , "second" + ] =?> + para ("first" <> linebreak <> "second") + , "disable author export" =: T.unlines [ "#+OPTIONS: author:nil" , "#+AUTHOR: ShyGuy" |