From aff2500d46012c78197102ae6ad59d77dc8c5637 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sun, 19 Apr 2020 17:21:19 -0700
Subject: [PATCH] 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.
---
 test/Tests/Readers/HTML.hs | 16 ++++++++++------
 1 file 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