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.
This commit is contained in:
parent
64e84d8a3e
commit
aff2500d46
1 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue