diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-25 22:13:03 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-25 22:13:41 -0700 |
commit | 5945c3b01197d17e48d06bef3dd76fa2547b245f (patch) | |
tree | 0f3715164338fe5df83a31201d9be3ca7d2e2361 /src | |
parent | 096cbe698746d621bfee9607b1ab826240082a10 (diff) | |
download | pandoc-5945c3b01197d17e48d06bef3dd76fa2547b245f.tar.gz |
Man reader: support tables.
Closes #4982.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index df740fa73..6f3a1a78d 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -115,21 +115,19 @@ parseTable = do isMTable _ = False MTable _opts aligns rows pos <- msatisfy isMTable case aligns of - [as] -> do + [as] -> try (do let as' = map (columnTypeToAlignment . columnType) as - if all isJust as' - then do - let alignments = catMaybes as' - let (headerRow', bodyRows') = - case rows of - (h:[x]:bs) - | isHrule x -> (h, bs) - _ -> ([], rows) - headerRow <- mapM parseTableCell headerRow' - bodyRows <- mapM (mapM parseTableCell) bodyRows' - return $ B.table mempty (zip alignments (repeat 0.0)) - headerRow bodyRows - else fallback pos + guard $ all isJust as' + let alignments = catMaybes as' + let (headerRow', bodyRows') = + case rows of + (h:[x]:bs) + | isHrule x -> (h, bs) + _ -> ([], rows) + headerRow <- mapM parseTableCell headerRow' + bodyRows <- mapM (mapM parseTableCell) bodyRows' + return $ B.table mempty (zip alignments (repeat 0.0)) + headerRow bodyRows) <|> fallback pos _ -> fallback pos where @@ -137,7 +135,10 @@ parseTable = do parseTableCell ts = do st <- getState let ts' = Foldable.toList $ unGroffTokens ts - res <- lift $ readWithMTokens (mconcat <$> many parseBlock <* eof) st ts' + let tcell = do + skipMany memptyLine + plain . trimInlines <$> (parseInlines <* eof) + res <- lift $ readWithMTokens tcell st ts' case res of Left e -> throwError e Right x -> return x |