aboutsummaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-12-04 10:31:06 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-12-04 14:56:57 -0800
commitae60e0196c5c12d358002cf3251dfebf07c66da6 (patch)
tree7c3bc1c605e6e65dbe4fe0071580e6ac92de5c00 /test/Tests
parentc58ecde93737aa68bd5dda9c4c72193dcaab3cf0 (diff)
downloadpandoc-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 'test/Tests')
-rw-r--r--test/Tests/Readers/Docx.hs27
1 files changed, 7 insertions, 20 deletions
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs
index b5d7aa430..421acaa8b 100644
--- a/test/Tests/Readers/Docx.hs
+++ b/test/Tests/Readers/Docx.hs
@@ -10,7 +10,6 @@ import Test.Tasty
import Test.Tasty.HUnit
import Tests.Helpers
import Text.Pandoc
-import Text.Pandoc.Shared (stripEmptyParagraphs)
import qualified Text.Pandoc.Class as P
import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
import Text.Pandoc.UTF8 as UTF8
@@ -38,23 +37,20 @@ instance ToString NoNormPandoc where
instance ToPandoc NoNormPandoc where
toPandoc = unNoNorm
-compareOutput :: Bool
- -> ReaderOptions
- -> FilePath
- -> FilePath
- -> IO (NoNormPandoc, NoNormPandoc)
-compareOutput strip opts docxFile nativeFile = do
+compareOutput :: ReaderOptions
+ -> FilePath
+ -> FilePath
+ -> IO (NoNormPandoc, NoNormPandoc)
+compareOutput opts docxFile nativeFile = do
df <- B.readFile docxFile
nf <- UTF8.toText <$> BS.readFile nativeFile
p <- runIOorExplode $ readDocx opts df
df' <- runIOorExplode $ readNative def nf
- return $ (noNorm (if strip
- then stripEmptyParagraphs p
- else p), noNorm df')
+ return $ (noNorm p, noNorm df')
testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO TestTree
testCompareWithOptsIO opts name docxFile nativeFile = do
- (dp, np) <- compareOutput True opts docxFile nativeFile
+ (dp, np) <- compareOutput opts docxFile nativeFile
return $ test id name (dp, np)
testCompareWithOpts :: ReaderOptions -> String -> FilePath -> FilePath -> TestTree
@@ -75,11 +71,6 @@ testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> Te
testForWarningsWithOpts opts name docxFile expected =
unsafePerformIO $ testForWarningsWithOptsIO opts name docxFile expected
-testCompareNoStrip :: String -> FilePath -> FilePath -> TestTree
-testCompareNoStrip name docxFile nativeFile = unsafePerformIO $ do
- (dp, np) <- compareOutput False defopts docxFile nativeFile
- return $ test id name (dp, np)
-
-- testForWarnings :: String -> FilePath -> [String] -> TestTree
-- testForWarnings = testForWarningsWithOpts defopts
@@ -266,10 +257,6 @@ tests = [ testGroup "inlines"
"dropcap paragraphs"
"docx/drop_cap.docx"
"docx/drop_cap.native"
- , testCompareNoStrip
- "empty paragraphs without stripping"
- "docx/drop_cap.docx"
- "docx/drop_cap_nostrip.native"
]
, testGroup "track changes"
[ testCompare