git.iko.soy/typeable/pandoc
on master help sign in
Org reader: support `\n` export option
514662eAlbert Krewinkel
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1
@@ -52,7 +52,7 @@ exportSetting = choice
52 , booleanSetting "-" (\val es -> es { exportSpecialStrings = val })
52 , booleanSetting "-" (\val es -> es { exportSpecialStrings = val })
53 , ignoredSetting ":"
53 , ignoredSetting ":"
54 , ignoredSetting "<"
54 , ignoredSetting "<"
55− , ignoredSetting "\\n"
55+ , booleanSetting "\\n" (\val es -> es { exportPreserveBreaks = val })
56 , archivedTreeSetting "arch" (\val es -> es { exportArchivedTrees = val })
56 , archivedTreeSetting "arch" (\val es -> es { exportArchivedTrees = val })
57 , booleanSetting "author" (\val es -> es { exportWithAuthor = val })
57 , booleanSetting "author" (\val es -> es { exportWithAuthor = val })
58 , ignoredSetting "c"
58 , ignoredSetting "c"
src/Text/Pandoc/Readers/Org/Inlines.hs+2−1
@@ -158,7 +158,8 @@ endline = try $ do
158 decEmphasisNewlinesCount
158 decEmphasisNewlinesCount
159 guard =<< newlinesCountWithinLimits
159 guard =<< newlinesCountWithinLimits
160 updateLastPreCharPos
160 updateLastPreCharPos
161+ useHardBreaks <- exportPreserveBreaks . orgStateExportSettings <$> getState
161− returnF B.softbreak
162+ returnF (if useHardBreaks then B.linebreak else B.softbreak)
162
163
163
164
164--
165--
src/Text/Pandoc/Readers/Org/ParserState.hs+2
@@ -242,6 +242,7 @@ data ExportSettings = ExportSettings
242 , exportEmphasizedText :: Bool -- ^ Parse emphasized text
242 , exportEmphasizedText :: Bool -- ^ Parse emphasized text
243 , exportHeadlineLevels :: Int
243 , exportHeadlineLevels :: Int
244 -- ^ Maximum depth of headlines, deeper headlines are convert to list
244 -- ^ Maximum depth of headlines, deeper headlines are convert to list
245+ , exportPreserveBreaks :: Bool -- ^ Whether to preserve linebreaks
245 , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
246 , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
246 , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
247 , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
247 , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
248 , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
@@ -261,6 +262,7 @@ defaultExportSettings = ExportSettings
261 , exportDrawers = Left ["LOGBOOK"]
262 , exportDrawers = Left ["LOGBOOK"]
262 , exportEmphasizedText = True
263 , exportEmphasizedText = True
263 , exportHeadlineLevels = 3
264 , exportHeadlineLevels = 3
265+ , exportPreserveBreaks = False
264 , exportSmartQuotes = False
266 , exportSmartQuotes = False
265 , exportSpecialStrings = True
267 , exportSpecialStrings = True
266 , exportSubSuperscripts = True
268 , exportSubSuperscripts = True
test/Tests/Readers/Org.hs+7
@@ -773,6 +773,13 @@ tests =
773 , para "top-level section 2" ]
773 , para "top-level section 2" ]
774 ]
774 ]
775
775
776+ , "preserve linebreaks as hard breaks" =:
777+ T.unlines [ "#+OPTIONS: \\n:t"
778+ , "first"
779+ , "second"
780+ ] =?>
781+ para ("first" <> linebreak <> "second")
782+
776 , "disable author export" =:
783 , "disable author export" =:
777 T.unlines [ "#+OPTIONS: author:nil"
784 T.unlines [ "#+OPTIONS: author:nil"
778 , "#+AUTHOR: ShyGuy"
785 , "#+AUTHOR: ShyGuy"