aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-10-31 00:16:26 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-10-31 00:16:58 +0300
commite874bc2c28fa8651446dd8b8fe6f43339b27de3a (patch)
tree31914d951a6c62a31c124ffa9f2414900ca5a3c4 /src/Text
parent51685cafded9791ffe9d0295f22107daec92ef43 (diff)
downloadpandoc-e874bc2c28fa8651446dd8b8fe6f43339b27de3a.tar.gz
Generalize gridTableWith to any streams with Char tokens
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Parsing.hs34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 90c2d09dc..82a043f53 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -932,20 +932,20 @@ widthsFromIndices numColumns' indices =
-- (which may be grid), then the rows,
-- which may be grid, separated by blank lines, and
-- ending with a footer (dashed line followed by blank line).
-gridTableWith :: (Monad m, HasReaderOptions st,
- Functor mf, Applicative mf, Monad mf)
- => ParserT [Char] st m (mf Blocks) -- ^ Block list parser
- -> Bool -- ^ Headerless table
- -> ParserT [Char] st m (mf Blocks)
+gridTableWith :: (Monad m, HasReaderOptions st, Stream s m Char,
+ Functor mf, Applicative mf, Monad mf, IsString s)
+ => ParserT s st m (mf Blocks) -- ^ Block list parser
+ -> Bool -- ^ Headerless table
+ -> ParserT s st m (mf Blocks)
gridTableWith blocks headless =
tableWith (gridTableHeader headless blocks) (gridTableRow blocks)
(gridTableSep '-') gridTableFooter
-gridTableWith' :: (Monad m, HasReaderOptions st,
- Functor mf, Applicative mf, Monad mf)
- => ParserT [Char] st m (mf Blocks) -- ^ Block list parser
- -> Bool -- ^ Headerless table
- -> ParserT [Char] st m (TableComponents mf)
+gridTableWith' :: (Monad m, HasReaderOptions st, Stream s m Char,
+ Functor mf, Applicative mf, Monad mf, IsString s)
+ => ParserT s st m (mf Blocks) -- ^ Block list parser
+ -> Bool -- ^ Headerless table
+ -> ParserT s st m (TableComponents mf)
gridTableWith' blocks headless =
tableWith' (gridTableHeader headless blocks) (gridTableRow blocks)
(gridTableSep '-') gridTableFooter
@@ -981,10 +981,11 @@ gridTableSep :: Stream s m Char => Char -> ParserT s st m Char
gridTableSep ch = try $ gridDashedLines ch >> return '\n'
-- | Parse header for a grid table.
-gridTableHeader :: (Monad m, Functor mf, Applicative mf, Monad mf)
+gridTableHeader :: (Monad m, Functor mf, Applicative mf, Monad mf,
+ Stream s m Char, IsString s)
=> Bool -- ^ Headerless table
- -> ParserT [Char] st m (mf Blocks)
- -> ParserT [Char] st m (mf [Blocks], [Alignment], [Int])
+ -> ParserT s st m (mf Blocks)
+ -> ParserT s st m (mf [Blocks], [Alignment], [Int])
gridTableHeader headless blocks = try $ do
optional blanklines
dashes <- gridDashedLines '-'
@@ -1014,10 +1015,11 @@ gridTableRawLine indices = do
return (gridTableSplitLine indices line)
-- | Parse row of grid table.
-gridTableRow :: (Monad m, Functor mf, Applicative mf, Monad mf)
- => ParserT [Char] st m (mf Blocks)
+gridTableRow :: (Monad m, Functor mf, Applicative mf, Monad mf,
+ Stream s m Char, IsString s)
+ => ParserT s st m (mf Blocks)
-> [Int]
- -> ParserT [Char] st m (mf [Blocks])
+ -> ParserT s st m (mf [Blocks])
gridTableRow blocks indices = do
colLines <- many1 (gridTableRawLine indices)
let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $