aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/GFM.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2017-08-07 09:13:36 -0700
committerJohn MacFarlane <[email protected]>2017-08-07 09:13:36 -0700
commit533395145b35913138adea4a4b4741b2b52fc61f (patch)
tree00eae9a7f7c04e4110ab03726fd17f26f147fd82 /src/Text/Pandoc/Readers/GFM.hs
parentc82ce46dd40a7fed393584ea309a685236c55122 (diff)
Got tables working in reader.commonmark-github
Diffstat (limited to 'src/Text/Pandoc/Readers/GFM.hs')
-rw-r--r--src/Text/Pandoc/Readers/GFM.hs33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/GFM.hs b/src/Text/Pandoc/Readers/GFM.hs
index 8726a6c3f..1cdc47b98 100644
--- a/src/Text/Pandoc/Readers/GFM.hs
+++ b/src/Text/Pandoc/Readers/GFM.hs
@@ -109,12 +109,43 @@ addBlock (Node _ (TABLE alignments) nodes) = do
isCell _ = False
toRow (Node _ TABLE_ROW ns) = map toCell $ filter isCell ns
toRow (Node _ t _) = error $ "toRow encountered non-row " ++ show t
- toCell (Node _ TABLE_CELL ns) = addBlocks ns
+ toCell (Node _ TABLE_CELL []) = []
+ toCell (Node _ TABLE_CELL (n:ns))
+ | isBlockNode n = addBlocks (n:ns)
+ | otherwise = [Plain (addInlines (n:ns))]
toCell (Node _ t _) = error $ "toCell encountered non-cell " ++ show t
addBlock (Node _ TABLE_ROW _) = id -- handled in TABLE
addBlock (Node _ TABLE_CELL _) = id -- handled in TABLE
addBlock _ = id
+isBlockNode :: Node -> Bool
+isBlockNode (Node _ nodetype _) =
+ case nodetype of
+ DOCUMENT -> True
+ THEMATIC_BREAK -> True
+ PARAGRAPH -> True
+ BLOCK_QUOTE -> True
+ HTML_BLOCK _ -> True
+ CUSTOM_BLOCK _ _ -> True
+ CODE_BLOCK _ _ -> True
+ HEADING _ -> True
+ LIST _ -> True
+ ITEM -> True
+ TEXT _ -> False
+ SOFTBREAK -> False
+ LINEBREAK -> False
+ HTML_INLINE _ -> False
+ CUSTOM_INLINE _ _ -> False
+ CODE _ -> False
+ EMPH -> False
+ STRONG -> False
+ LINK _ _ -> False
+ IMAGE _ _ -> False
+ STRIKETHROUGH -> False
+ TABLE _ -> False
+ TABLE_ROW -> False
+ TABLE_CELL -> False
+
children :: Node -> [Node]
children (Node _ _ ns) = ns