Org reader: support \n export option

The `\n` export option turns all newlines in the text into hard
linebreaks.

Closes #3950
This commit is contained in:
Albert Krewinkel 2017-10-02 23:11:58 +02:00
parent 3e77ea4792
commit 514662e544
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
4 changed files with 12 additions and 2 deletions

View file

@ -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"

View file

@ -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)
--

View file

@ -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

View file

@ -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"