diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2020-11-24 13:48:43 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2020-11-24 14:17:35 +0100 |
commit | c9f98e2bf5635564bbd83f97c32567dea121d317 (patch) | |
tree | 04dd1c105e146951dbdf57259561c311228c05d0 /src/Text/Pandoc/Readers/HTML.hs | |
parent | 446ef27a3fb69d6ddf2e841dbdb9dc9c6f288928 (diff) | |
download | pandoc-c9f98e2bf5635564bbd83f97c32567dea121d317.tar.gz |
HTML reader: support row or column-spanning table cells
Diffstat (limited to 'src/Text/Pandoc/Readers/HTML.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 177a39be0..e33dface7 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -476,18 +476,10 @@ pHrule = do pTable :: PandocMonad m => TagParser m Blocks pTable = pTable' block pCell -noColOrRowSpans :: Tag Text -> Bool -noColOrRowSpans t = isNullOrOne "colspan" && isNullOrOne "rowspan" - where isNullOrOne x = case fromAttrib x t of - "" -> True - "1" -> True - _ -> False - -pCell :: PandocMonad m => Text -> TagParser m [(Alignment, Blocks)] +pCell :: PandocMonad m => Text -> TagParser m [Cell] pCell celltype = try $ do skipMany pBlank - tag <- lookAhead $ - pSatisfy (\t -> t ~== TagOpen celltype [] && noColOrRowSpans t) + tag <- lookAhead $ pSatisfy (\t -> t ~== TagOpen celltype []) let extractAlign' [] = "" extractAlign' ("text-align":x:_) = x extractAlign' (_:xs) = extractAlign' xs @@ -498,9 +490,13 @@ pCell celltype = try $ do Just "right" -> AlignRight Just "center" -> AlignCenter _ -> AlignDefault - res <- pInTags' celltype noColOrRowSpans block + let rowspan = RowSpan . fromMaybe 1 $ + safeRead =<< maybeFromAttrib "rowspan" tag + let colspan = ColSpan . fromMaybe 1 $ + safeRead =<< maybeFromAttrib "colspan" tag + res <- pInTags celltype block skipMany pBlank - return [(align, res)] + return [B.cell align rowspan colspan res] pBlockQuote :: PandocMonad m => TagParser m Blocks pBlockQuote = do |