@@ -109,12 +109,43 @@ addBlock (Node _ (TABLE alignments) nodes) = do
109109 isCell _ = False
110110 toRow (Node _ TABLE_ROW ns) = map toCell $ filter isCell ns
111111 toRow (Node _ t _) = error $ "toRow encountered non-row " ++ show t
112− toCell (Node _ TABLE_CELL ns) = addBlocks ns
112+ toCell (Node _ TABLE_CELL []) = []
113+ toCell (Node _ TABLE_CELL (n:ns))
114+ | isBlockNode n = addBlocks (n:ns)
115+ | otherwise = [Plain (addInlines (n:ns))]
113116 toCell (Node _ t _) = error $ "toCell encountered non-cell " ++ show t
114117addBlock (Node _ TABLE_ROW _) = id -- handled in TABLE
115118addBlock (Node _ TABLE_CELL _) = id -- handled in TABLE
116119addBlock _ = id
117120
121+isBlockNode :: Node -> Bool
122+isBlockNode (Node _ nodetype _) =
123+ case nodetype of
124+ DOCUMENT -> True
125+ THEMATIC_BREAK -> True
126+ PARAGRAPH -> True
127+ BLOCK_QUOTE -> True
128+ HTML_BLOCK _ -> True
129+ CUSTOM_BLOCK _ _ -> True
130+ CODE_BLOCK _ _ -> True
131+ HEADING _ -> True
132+ LIST _ -> True
133+ ITEM -> True
134+ TEXT _ -> False
135+ SOFTBREAK -> False
136+ LINEBREAK -> False
137+ HTML_INLINE _ -> False
138+ CUSTOM_INLINE _ _ -> False
139+ CODE _ -> False
140+ EMPH -> False
141+ STRONG -> False
142+ LINK _ _ -> False
143+ IMAGE _ _ -> False
144+ STRIKETHROUGH -> False
145+ TABLE _ -> False
146+ TABLE_ROW -> False
147+ TABLE_CELL -> False
148+
118149children :: Node -> [Node]
119150children (Node _ _ ns) = ns
120151