diff options
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 15 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/CommonMark.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 2 |
5 files changed, 7 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index e3c3d00e6..8de9ebc19 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -61,7 +61,7 @@ import Text.Pandoc.Options ( import Text.Pandoc.Parsing hiding ((<|>)) import Text.Pandoc.Shared (addMetaField, blocksToInlines', crFilter, escapeURI, extractSpaces, htmlSpanLikeElements, elemText, splitTextBy, - onlySimpleCellBodies, safeRead, underlineSpan, tshow) + onlySimpleTableCells, safeRead, underlineSpan, tshow) import Text.Pandoc.Walk import Text.Parsec.Error import Text.TeXMath (readMathML, writeTeX) @@ -499,7 +499,7 @@ pTable = try $ do let rows''' = map (map snd) rows'' -- fail on empty table guard $ not $ null head' && null rows''' - let isSimple = onlySimpleCellBodies $ fmap B.toList <$> head':rows''' + let isSimple = onlySimpleTableCells $ fmap B.toList <$> head':rows''' let cols = if null head' then maximum (map length rows''') else length head' diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 846e7699c..0418aa6e2 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -67,7 +67,6 @@ module Text.Pandoc.Shared ( headerShift, stripEmptyParagraphs, onlySimpleTableCells, - onlySimpleCellBodies, isTightList, taskListItemFromAscii, taskListItemToAscii, @@ -669,18 +668,8 @@ stripEmptyParagraphs = walk go -- | Detect if table rows contain only cells consisting of a single -- paragraph that has no @LineBreak@. - --- TODO: should this become aware of cell dimensions? -onlySimpleTableCells :: [Row] -> Bool -onlySimpleTableCells = onlySimpleCellBodies . map unRow - where - unRow (Row _ body) = map unCell body - unCell (Cell _ _ _ _ body) = body - --- | Detect if unwrapped table rows contain only cells consisting of a --- single paragraph that has no @LineBreak@. -onlySimpleCellBodies :: [[[Block]]] -> Bool -onlySimpleCellBodies = all isSimpleCell . concat +onlySimpleTableCells :: [[[Block]]] -> Bool +onlySimpleTableCells = all isSimpleCell . concat where isSimpleCell [Plain ils] = not (hasLineBreak ils) isSimpleCell [Para ils ] = not (hasLineBreak ils) diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs index 585f7137e..bd798ee73 100644 --- a/src/Text/Pandoc/Writers/CommonMark.hs +++ b/src/Text/Pandoc/Writers/CommonMark.hs @@ -156,7 +156,7 @@ blockToNodes opts (DefinitionList items) ns = Para term : concat xs blockToNodes opts t@(Table _ blkCapt specs _ thead tbody tfoot) ns = let (capt, aligns, _widths, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot - in if isEnabled Ext_pipe_tables opts && onlySimpleTableCells (thead <> tbody <> tfoot) + in if isEnabled Ext_pipe_tables opts && onlySimpleTableCells (headers : rows) then do -- We construct a table manually as a CUSTOM_BLOCK, for -- two reasons: (1) cmark-gfm currently doesn't support diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 5501b49ee..4d4d02028 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -582,7 +582,7 @@ blockToMarkdown' opts t@(Table _ blkCapt specs _ thead tbody tfoot) = do let caption'' = if null caption || not (isEnabled Ext_table_captions opts) then blankline else blankline $$ (": " <> caption') $$ blankline - let hasSimpleCells = onlySimpleTableCells $ thead <> tbody <> tfoot + let hasSimpleCells = onlySimpleTableCells $ headers : rows let isSimple = hasSimpleCells && all (==0) widths let isPlainBlock (Plain _) = True isPlainBlock _ = False diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 8f672a8bd..f2bc91290 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -270,7 +270,7 @@ blockToMuse (Table _ blkCapt specs _ thead tbody tfoot) = blocksToDoc opts blocks = local (\env -> env { envOptions = opts }) $ blockListToMuse blocks numcols = maximum (length aligns : length widths : map length (headers:rows)) - isSimple = onlySimpleTableCells (thead <> tbody <> tfoot) && all (== 0) widths + isSimple = onlySimpleTableCells (headers : rows) && all (== 0) widths blockToMuse (Div _ bs) = flatBlockListToMuse bs blockToMuse Null = return empty |