@@ -528,15 +528,15 @@ rawLaTeXEnvironment' = do
531−-- | Parse a dashed line with optional trailing spaces; return its length
531+-- Parse a dashed line with optional trailing spaces; return its length
532−-- and the length including trailing space.
532+-- and the length including trailing space.
533dashedLine ch = do
533dashedLine ch = do
534 dashes <- many1 (char ch)
534 dashes <- many1 (char ch)
535 sp <- many spaceChar
535 sp <- many spaceChar
536 return $ (length dashes, length $ dashes ++ sp)
536 return $ (length dashes, length $ dashes ++ sp)
538−-- | Parse a table header with dashed lines of '-' preceded by
538+-- Parse a table header with dashed lines of '-' preceded by
539−-- one line of text.
539+-- one line of text.
540simpleTableHeader = do
540simpleTableHeader = do
541 rawContent <- anyLine
541 rawContent <- anyLine
542 initSp <- nonindentSpaces
542 initSp <- nonindentSpaces
@@ -548,41 +548,41 @@ simpleTableHeader = do
548 let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths
548 let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths
549 return $ (rawHeads, aligns, indices)
549 return $ (rawHeads, aligns, indices)
551−-- | Parse a table footer - dashed lines followed by blank line.
551+-- Parse a table footer - dashed lines followed by blank line.
552tableFooter = try $ do
552tableFooter = try $ do
553 nonindentSpaces
553 nonindentSpaces
554 many1 (dashedLine '-')
554 many1 (dashedLine '-')
555 blanklines
555 blanklines
557−-- | Parse a table separator - dashed line.
557+-- Parse a table separator - dashed line.
558tableSep = try $ do
558tableSep = try $ do
559 nonindentSpaces
559 nonindentSpaces
560 many1 (dashedLine '-')
560 many1 (dashedLine '-')
561 string "\n"
561 string "\n"
563−-- | Parse a raw line and split it into chunks by indices.
563+-- Parse a raw line and split it into chunks by indices.
564rawTableLine indices = do
564rawTableLine indices = do
565 notFollowedBy' (blanklines <|> tableFooter)
565 notFollowedBy' (blanklines <|> tableFooter)
566 line <- many1Till anyChar newline
566 line <- many1Till anyChar newline
567 return $ map removeLeadingTrailingSpace $ tail $
567 return $ map removeLeadingTrailingSpace $ tail $
568 splitByIndices (init indices) line
568 splitByIndices (init indices) line
570−-- | Parse a table line and return a list of lists of blocks (columns).
570+-- Parse a table line and return a list of lists of blocks (columns).
571tableLine indices = try $ do
571tableLine indices = try $ do
572 rawline <- rawTableLine indices
572 rawline <- rawTableLine indices
573 mapM (parseFromStr (many plain)) rawline
573 mapM (parseFromStr (many plain)) rawline
575−-- | Parse a multiline table row and return a list of blocks (columns).
575+-- Parse a multiline table row and return a list of blocks (columns).
576multilineRow indices = try $ do
576multilineRow indices = try $ do
577 colLines <- many1 (rawTableLine indices)
577 colLines <- many1 (rawTableLine indices)
578 option "" blanklines
578 option "" blanklines
579 let cols = map unlines $ transpose colLines
579 let cols = map unlines $ transpose colLines
580 mapM (parseFromStr (many plain)) cols
580 mapM (parseFromStr (many plain)) cols
582−-- | Calculate relative widths of table columns, based on indices
582+-- Calculate relative widths of table columns, based on indices
583−widthsFromIndices :: Int -- ^ Number of columns on terminal
583+widthsFromIndices :: Int -- Number of columns on terminal
584− -> [Int] -- ^ Indices
584+ -> [Int] -- Indices
585− -> [Float] -- ^ Fractional relative sizes of columns
585+ -> [Float] -- Fractional relative sizes of columns
586widthsFromIndices _ [] = []
586widthsFromIndices _ [] = []
587widthsFromIndices numColumns indices =
587widthsFromIndices numColumns indices =
588 let lengths = zipWith (-) indices (0:indices)
588 let lengths = zipWith (-) indices (0:indices)
@@ -593,8 +593,8 @@ widthsFromIndices numColumns indices =
593 fracs = map (\l -> (fromIntegral l) / quotient) lengths in
593 fracs = map (\l -> (fromIntegral l) / quotient) lengths in
594 tail fracs
594 tail fracs
596−-- | Parses a table caption: inlines beginning with 'Table:'
596+-- Parses a table caption: inlines beginning with 'Table:'
597−-- and followed by blank lines
597+-- and followed by blank lines.
598tableCaption = try $ do
598tableCaption = try $ do
599 nonindentSpaces
599 nonindentSpaces
600 string "Table:"
600 string "Table:"
@@ -602,7 +602,7 @@ tableCaption = try $ do
602 blanklines
602 blanklines
603 return $ normalizeSpaces result
603 return $ normalizeSpaces result
605−-- | Parse a table using 'headerParser', 'lineParser', and 'footerParser'
605+-- Parse a table using 'headerParser', 'lineParser', and 'footerParser'.
606tableWith headerParser lineParser footerParser = try $ do
606tableWith headerParser lineParser footerParser = try $ do
607 (rawHeads, aligns, indices) <- headerParser
607 (rawHeads, aligns, indices) <- headerParser
608 lines <- many1Till (lineParser indices) footerParser
608 lines <- many1Till (lineParser indices) footerParser
@@ -613,13 +613,13 @@ tableWith headerParser lineParser footerParser = try $ do
613 let widths = widthsFromIndices numColumns indices
613 let widths = widthsFromIndices numColumns indices
614 return $ Table caption aligns widths heads lines
614 return $ Table caption aligns widths heads lines
616−-- | Parse a simple table with '---' header and one line per row.
616+-- Parse a simple table with '---' header and one line per row.
617simpleTable = tableWith simpleTableHeader tableLine blanklines
617simpleTable = tableWith simpleTableHeader tableLine blanklines
619−-- | Parse a multiline table: starts with row of '-' on top, then header
619+-- Parse a multiline table: starts with row of '-' on top, then header
620−-- (which may be multiline), then the rows,
620+-- (which may be multiline), then the rows,
621−-- which may be multiline, separated by blank lines, and
621+-- which may be multiline, separated by blank lines, and
622−-- ending with a footer (dashed line followed by blank line).
622+-- ending with a footer (dashed line followed by blank line).
623multilineTable = tableWith multilineTableHeader multilineRow tableFooter
623multilineTable = tableWith multilineTableHeader multilineRow tableFooter
625multilineTableHeader = try $ do
625multilineTableHeader = try $ do
@@ -639,7 +639,7 @@ multilineTableHeader = try $ do
639 return $ ((map removeLeadingTrailingSpace rawHeads),
639 return $ ((map removeLeadingTrailingSpace rawHeads),
640 aligns, indices)
640 aligns, indices)
642−-- | Returns the longest of a list of strings.
642+-- Returns the longest of a list of strings.
643longest :: [String] -> String
643longest :: [String] -> String
644longest [] = ""
644longest [] = ""
645longest [x] = x
645longest [x] = x
@@ -648,9 +648,9 @@ longest (x:xs) =
649 else longest xs
649 else longest xs
651−-- | Returns an alignment type for a table, based on a list of strings
651+-- Returns an alignment type for a table, based on a list of strings
652−-- (the rows of the column header) and a number (the length of the
652+-- (the rows of the column header) and a number (the length of the
653−-- dashed line under the rows.
653+-- dashed line under the rows.
654alignType :: [String] -> Int -> Alignment
654alignType :: [String] -> Int -> Alignment
655alignType [] len = AlignDefault
655alignType [] len = AlignDefault
656alignType strLst len =
656alignType strLst len =