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:
parent
3e77ea4792
commit
514662e544
4 changed files with 12 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
--
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue