aboutsummaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-04-19 17:21:19 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-04-19 17:21:19 -0700
commitaff2500d46012c78197102ae6ad59d77dc8c5637 (patch)
tree4bdbe1806993cb68ac6996e07f97a10a56144f0a /test/Tests
parent64e84d8a3e043677ec20cdcd78bce2f405f8bac8 (diff)
downloadpandoc-aff2500d46012c78197102ae6ad59d77dc8c5637.tar.gz
More fixes for round-trip tests of HTML reader.
We exclude tables that have default widths but non-simple content, as these can't really round-trip.
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Readers/HTML.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs
index c359288e8..b9fe8b501 100644
--- a/test/Tests/Readers/HTML.hs
+++ b/test/Tests/Readers/HTML.hs
@@ -21,7 +21,8 @@ import Test.Tasty.QuickCheck
import Test.Tasty.Options (IsOption(defaultValue))
import Tests.Helpers
import Text.Pandoc
-import Text.Pandoc.Shared (isHeaderBlock)
+import Text.Pandoc.Writers.Shared (toLegacyTable)
+import Text.Pandoc.Shared (isHeaderBlock, onlySimpleTableCells)
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
import Text.Pandoc.Walk (walk)
@@ -36,16 +37,19 @@ makeRoundTrip :: Block -> Block
makeRoundTrip CodeBlock{} = Para [Str "code block was here"]
makeRoundTrip LineBlock{} = Para [Str "line block was here"]
makeRoundTrip RawBlock{} = Para [Str "raw block was here"]
-makeRoundTrip b@Table{} = walk rmLineBreaks b
makeRoundTrip (Div attr bs) = Div attr $ filter (not . isHeaderBlock) bs
-- avoids round-trip failures related to makeSections
-- e.g. with [Div ("loc",[],[("a","11"),("b_2","a b c")]) [Header 3 ("",[],[]) []]]
+makeRoundTrip b@(Table _attr blkCapt specs thead tbody tfoot) =
+ let (_capt, _aligns, widths, headers, rows') =
+ toLegacyTable blkCapt specs thead tbody tfoot
+ isSimple = onlySimpleTableCells (headers:rows')
+ in
+ if all (== 0.0) widths && not isSimple
+ then Para [Str "weird table omitted"]
+ else b
makeRoundTrip x = x
-rmLineBreaks :: Inline -> Inline
-rmLineBreaks LineBreak = SoftBreak
-rmLineBreaks x = x
-
removeRawInlines :: Inline -> Inline
removeRawInlines RawInline{} = Str "raw inline was here"
removeRawInlines x = x