git.iko.soy/typeable/pandoc
on master help sign in
Remove the onlySimpleCellBodies function from Shared
commitf8ce38975b547fe7fc8c12ccee3a940b35d8b9cf authordespresc <christian.j.j.despres@gmail.com> dateSat 28 Mar 2020, 19:06 (7 years ago) parent7254a2a
5 files changed+7−18
src/Text/Pandoc/Readers/HTML.hs+2−2 src/Text/Pandoc/Shared.hs+2−13 src/Text/Pandoc/Writers/CommonMark.hs+1−1 src/Text/Pandoc/Writers/Markdown.hs+1−1 src/Text/Pandoc/Writers/Muse.hs+1−1
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -61,7 +61,7 @@ import Text.Pandoc.Options (
6161import Text.Pandoc.Parsing hiding ((<|>))
6262import Text.Pandoc.Shared (addMetaField, blocksToInlines', crFilter, escapeURI,
6363 extractSpaces, htmlSpanLikeElements, elemText, splitTextBy,
64− onlySimpleCellBodies, safeRead, underlineSpan, tshow)
64+ onlySimpleTableCells, safeRead, underlineSpan, tshow)
6565import Text.Pandoc.Walk
6666import Text.Parsec.Error
6767import Text.TeXMath (readMathML, writeTeX)
@@ -499,7 +499,7 @@ pTable = try $ do
499499 let rows''' = map (map snd) rows''
500500 -- fail on empty table
501501 guard $ not $ null head' && null rows'''
502− let isSimple = onlySimpleCellBodies $ fmap B.toList <$> head':rows'''
502+ let isSimple = onlySimpleTableCells $ fmap B.toList <$> head':rows'''
503503 let cols = if null head'
504504 then maximum (map length rows''')
505505 else length head'
src/Text/Pandoc/Shared.hs+2−13
@@ -67,7 +67,6 @@ module Text.Pandoc.Shared (
6767 headerShift,
6868 stripEmptyParagraphs,
6969 onlySimpleTableCells,
70− onlySimpleCellBodies,
7170 isTightList,
7271 taskListItemFromAscii,
7372 taskListItemToAscii,
@@ -669,18 +668,8 @@ stripEmptyParagraphs = walk go
669668
670669-- | Detect if table rows contain only cells consisting of a single
671670-- paragraph that has no @LineBreak@.
672−
673−-- TODO: should this become aware of cell dimensions?
674−onlySimpleTableCells :: [Row] -> Bool
675−onlySimpleTableCells = onlySimpleCellBodies . map unRow
676− where
677− unRow (Row _ body) = map unCell body
678− unCell (Cell _ _ _ _ body) = body
679−
680−-- | Detect if unwrapped table rows contain only cells consisting of a
681−-- single paragraph that has no @LineBreak@.
682−onlySimpleCellBodies :: [[[Block]]] -> Bool
683−onlySimpleCellBodies = all isSimpleCell . concat
671+onlySimpleTableCells :: [[[Block]]] -> Bool
672+onlySimpleTableCells = all isSimpleCell . concat
684673 where
685674 isSimpleCell [Plain ils] = not (hasLineBreak ils)
686675 isSimpleCell [Para ils ] = not (hasLineBreak ils)
src/Text/Pandoc/Writers/CommonMark.hs+1−1
@@ -156,7 +156,7 @@ blockToNodes opts (DefinitionList items) ns =
156156 Para term : concat xs
157157blockToNodes opts t@(Table _ blkCapt specs _ thead tbody tfoot) ns =
158158 let (capt, aligns, _widths, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot
159− in if isEnabled Ext_pipe_tables opts && onlySimpleTableCells (thead <> tbody <> tfoot)
159+ in if isEnabled Ext_pipe_tables opts && onlySimpleTableCells (headers : rows)
160160 then do
161161 -- We construct a table manually as a CUSTOM_BLOCK, for
162162 -- two reasons: (1) cmark-gfm currently doesn't support
src/Text/Pandoc/Writers/Markdown.hs+1−1
@@ -582,7 +582,7 @@ blockToMarkdown' opts t@(Table _ blkCapt specs _ thead tbody tfoot) = do
582582 let caption'' = if null caption || not (isEnabled Ext_table_captions opts)
583583 then blankline
584584 else blankline $$ (": " <> caption') $$ blankline
585− let hasSimpleCells = onlySimpleTableCells $ thead <> tbody <> tfoot
585+ let hasSimpleCells = onlySimpleTableCells $ headers : rows
586586 let isSimple = hasSimpleCells && all (==0) widths
587587 let isPlainBlock (Plain _) = True
588588 isPlainBlock _ = False
src/Text/Pandoc/Writers/Muse.hs+1−1
@@ -270,7 +270,7 @@ blockToMuse (Table _ blkCapt specs _ thead tbody tfoot) =
270270 blocksToDoc opts blocks =
271271 local (\env -> env { envOptions = opts }) $ blockListToMuse blocks
272272 numcols = maximum (length aligns : length widths : map length (headers:rows))
273− isSimple = onlySimpleTableCells (thead <> tbody <> tfoot) && all (== 0) widths
273+ isSimple = onlySimpleTableCells (headers : rows) && all (== 0) widths
274274blockToMuse (Div _ bs) = flatBlockListToMuse bs
275275blockToMuse Null = return empty
276276