summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Parsing.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-01-27 21:30:35 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-27 21:30:35 +0100
commit56f74cb0abdcf991f26b7456ed69d99e1993d0ab (patch)
treeb9ce00483cb1100a3054e7df947c4b6607811e15 /src/Text/Pandoc/Parsing.hs
parent86b9a51ee3df623b4f09588e2d07ce0e36e23f29 (diff)
Removed Shared.compactify.
Changed signatures on Parsing.tableWith and Parsing.gridTableWith.
Diffstat (limited to 'src/Text/Pandoc/Parsing.hs')
-rw-r--r--src/Text/Pandoc/Parsing.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index e8f4c776c..b1cc8cc48 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -740,11 +740,11 @@ lineBlockLines = try $ do
-- | Parse a table using 'headerParser', 'rowParser',
-- 'lineParser', and 'footerParser'.
tableWith :: Stream s m Char
- => ParserT s ParserState m ([[Block]], [Alignment], [Int])
- -> ([Int] -> ParserT s ParserState m [[Block]])
+ => ParserT s ParserState m ([Blocks], [Alignment], [Int])
+ -> ([Int] -> ParserT s ParserState m [Blocks])
-> ParserT s ParserState m sep
-> ParserT s ParserState m end
- -> ParserT s ParserState m Block
+ -> ParserT s ParserState m Blocks
tableWith headerParser rowParser lineParser footerParser = try $ do
(heads, aligns, indices) <- headerParser
lines' <- rowParser indices `sepEndBy1` lineParser
@@ -753,7 +753,7 @@ tableWith headerParser rowParser lineParser footerParser = try $ do
let widths = if (indices == [])
then replicate (length aligns) 0.0
else widthsFromIndices numColumns indices
- return $ Table [] aligns widths heads lines'
+ return $ B.table mempty (zip aligns widths) heads lines'
-- Calculate relative widths of table columns, based on indices
widthsFromIndices :: Int -- Number of columns on terminal
@@ -787,9 +787,9 @@ widthsFromIndices numColumns' indices =
-- which may be grid, separated by blank lines, and
-- ending with a footer (dashed line followed by blank line).
gridTableWith :: Stream [Char] m Char
- => ParserT [Char] ParserState m [Block] -- ^ Block list parser
+ => ParserT [Char] ParserState m Blocks -- ^ Block list parser
-> Bool -- ^ Headerless table
- -> ParserT [Char] ParserState m Block
+ -> ParserT [Char] ParserState m Blocks
gridTableWith blocks headless =
tableWith (gridTableHeader headless blocks) (gridTableRow blocks)
(gridTableSep '-') gridTableFooter
@@ -818,8 +818,8 @@ gridTableSep ch = try $ gridDashedLines ch >> return '\n'
-- | Parse header for a grid table.
gridTableHeader :: Stream [Char] m Char
=> Bool -- ^ Headerless table
- -> ParserT [Char] ParserState m [Block]
- -> ParserT [Char] ParserState m ([[Block]], [Alignment], [Int])
+ -> ParserT [Char] ParserState m Blocks
+ -> ParserT [Char] ParserState m ([Blocks], [Alignment], [Int])
gridTableHeader headless blocks = try $ do
optional blanklines
dashes <- gridDashedLines '-'
@@ -850,9 +850,9 @@ gridTableRawLine indices = do
-- | Parse row of grid table.
gridTableRow :: Stream [Char] m Char
- => ParserT [Char] ParserState m [Block]
+ => ParserT [Char] ParserState m Blocks
-> [Int]
- -> ParserT [Char] ParserState m [[Block]]
+ -> ParserT [Char] ParserState m [Blocks]
gridTableRow blocks indices = do
colLines <- many1 (gridTableRawLine indices)
let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
@@ -867,8 +867,8 @@ removeOneLeadingSpace xs =
where startsWithSpace "" = True
startsWithSpace (y:_) = y == ' '
-compactifyCell :: [Block] -> [Block]
-compactifyCell bs = head $ compactify [bs]
+compactifyCell :: Blocks -> Blocks
+compactifyCell bs = head $ compactify' [bs]
-- | Parse footer for a grid table.
gridTableFooter :: Stream s m Char => ParserT s ParserState m [Char]