@@ -86,8 +86,8 @@ import Text.Pandoc.Lua (LuaException (..), runLuaFilter)
8686import Text.Pandoc.PDF (makePDF)
8787import Text.Pandoc.Process (pipeProcess)
8888import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained)
89−import Text.Pandoc.Shared (eastAsianLineBreakFilter, headerShift, isURI, ordNub,
90− safeRead, tabFilter)
89+import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs,
90+ headerShift, isURI, ordNub, safeRead, tabFilter)
9191import qualified Text.Pandoc.UTF8 as UTF8
9292import Text.Pandoc.Writers.Math (defaultKaTeXURL, defaultMathJaxURL)
9393import Text.Pandoc.XML (toEntities)
@@ -461,14 +461,17 @@ convertWithOpts opts = do
461461
462462 let transforms = (case optBaseHeaderLevel opts of
463463 x | x > 1 -> (headerShift (x - 1) :)
464− | otherwise -> id) $
464+ | otherwise -> id) .
465+ (if optStripEmptyParagraphs opts
466+ then (stripEmptyParagraphs :)
467+ else id) .
465468 (if extensionEnabled Ext_east_asian_line_breaks
466469 readerExts &&
467470 not (extensionEnabled Ext_east_asian_line_breaks
468471 writerExts &&
469472 writerWrapText writerOptions == WrapPreserve)
470473 then (eastAsianLineBreakFilter :)
471− else id)
474+ else id) $
472475 []
473476
474477 let sourceToDoc :: [FilePath] -> PandocIO Pandoc
@@ -622,6 +625,7 @@ data Opt = Opt
622625 , optLuaFilters :: [FilePath] -- ^ Lua filters to apply
623626 , optEmailObfuscation :: ObfuscationMethod
624627 , optIdentifierPrefix :: String
628+ , optStripEmptyParagraphs :: Bool -- ^ Strip empty paragraphs
625629 , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
626630 , optDataDir :: Maybe FilePath
627631 , optCiteMethod :: CiteMethod -- ^ Method to output cites
@@ -694,6 +698,7 @@ defaultOpts = Opt
694698 , optLuaFilters = []
695699 , optEmailObfuscation = NoObfuscation
696700 , optIdentifierPrefix = ""
701+ , optStripEmptyParagraphs = False
697702 , optIndentedCodeClasses = []
698703 , optDataDir = Nothing
699704 , optCiteMethod = Citeproc
@@ -940,7 +945,12 @@ options =
940945 "NUMBER")
941946 "" -- "Headers base level"
942947
943− , Option "" ["indented-code-classes"]
948+ , Option "" ["strip-empty-paragraphs"]
949+ (NoArg
950+ (\opt -> return opt{ optStripEmptyParagraphs = True }))
951+ "" -- "Strip empty paragraphs"
952+
953+ , Option "" ["indented-code-classes"]
944954 (ReqArg
945955 (\arg opt -> return opt { optIndentedCodeClasses = words $
946956 map (\c -> if c == ',' then ' ' else c) arg })