diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-12-04 10:31:06 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-12-04 14:56:57 -0800 |
commit | ae60e0196c5c12d358002cf3251dfebf07c66da6 (patch) | |
tree | 7c3bc1c605e6e65dbe4fe0071580e6ac92de5c00 /src/Text/Pandoc/Readers | |
parent | c58ecde93737aa68bd5dda9c4c72193dcaab3cf0 (diff) | |
download | pandoc-ae60e0196c5c12d358002cf3251dfebf07c66da6.tar.gz |
Add `empty_paragraphs` extension.
* Deprecate `--strip-empty-paragraphs` option. Instead we now
use an `empty_paragraphs` extension that can be enabled on
the reader or writer. By default, disabled.
* Add `Ext_empty_paragraphs` constructor to `Extension`.
* Revert "Docx reader: don't strip out empty paragraphs."
This reverts commit d6c58eb836f033a48955796de4d9ffb3b30e297b.
* Implement `empty_paragraphs` extension in docx reader and writer,
opendocument writer, html reader and writer.
* Add tests for `empty_paragraphs` extension.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 1fac98b14..651d46753 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -534,7 +534,10 @@ bodyPartToBlocks (Paragraph pPr parparts) then do modify $ \s -> s { docxDropCap = ils' } return mempty else do modify $ \s -> s { docxDropCap = mempty } - return $ parStyleToTransform pPr $ para ils' + opts <- asks docxOptions + if isNull ils' && not (isEnabled Ext_empty_paragraphs opts) + then return mempty + else return $ parStyleToTransform pPr $ para ils' bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do let kvs = case levelInfo of diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 24935fcd7..b0f5d38f9 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -68,9 +68,11 @@ import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps) import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Logging -import Text.Pandoc.Options (Extension (Ext_epub_html_exts, Ext_native_divs, Ext_native_spans, Ext_raw_html), - ReaderOptions (readerExtensions, readerStripComments), - extensionEnabled) +import Text.Pandoc.Options ( + Extension (Ext_epub_html_exts, Ext_empty_paragraphs, Ext_native_divs, + Ext_native_spans, Ext_raw_html), + ReaderOptions (readerExtensions, readerStripComments), + extensionEnabled) import Text.Pandoc.Parsing hiding ((<|>)) import Text.Pandoc.Shared (addMetaField, crFilter, escapeURI, extractSpaces, safeRead, underlineSpan) @@ -575,7 +577,10 @@ pPlain = do pPara :: PandocMonad m => TagParser m Blocks pPara = do contents <- trimInlines <$> pInTags "p" inline - return $ B.para contents + (do guardDisabled Ext_empty_paragraphs + guard (B.isNull contents) + return mempty) + <|> return (B.para contents) pFigure :: PandocMonad m => TagParser m Blocks pFigure = try $ do |