parent
b306405caa
commit
007eb96e06
3 changed files with 35 additions and 7 deletions
|
@ -1221,11 +1221,20 @@ removeOneLeadingSpace xs =
|
|||
gridTableFooter :: MarkdownParser [Char]
|
||||
gridTableFooter = blanklines
|
||||
|
||||
pipeBreak :: MarkdownParser [Alignment]
|
||||
pipeBreak = try $ do
|
||||
nonindentSpaces
|
||||
openPipe <- (True <$ char '|') <|> return False
|
||||
first <- pipeTableHeaderPart
|
||||
rest <- many $ sepPipe *> pipeTableHeaderPart
|
||||
-- surrounding pipes needed for a one-column table:
|
||||
guard $ not (null rest && not openPipe)
|
||||
optional (char '|')
|
||||
blankline
|
||||
return (first:rest)
|
||||
|
||||
pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
|
||||
pipeTable = try $ do
|
||||
let pipeBreak = nonindentSpaces *> optional (char '|') *>
|
||||
pipeTableHeaderPart `sepBy1` sepPipe <*
|
||||
optional (char '|') <* blankline
|
||||
(heads,aligns) <- try ( pipeBreak >>= \als ->
|
||||
return (return $ replicate (length als) mempty, als))
|
||||
<|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
|
||||
|
@ -1244,12 +1253,13 @@ sepPipe = try $ do
|
|||
pipeTableRow :: MarkdownParser (F [Blocks])
|
||||
pipeTableRow = do
|
||||
nonindentSpaces
|
||||
optional (char '|')
|
||||
openPipe <- (True <$ char '|') <|> return False
|
||||
let cell = mconcat <$>
|
||||
many (notFollowedBy (blankline <|> char '|') >> inline)
|
||||
first <- cell
|
||||
sepPipe
|
||||
rest <- cell `sepBy1` sepPipe
|
||||
rest <- many $ sepPipe *> cell
|
||||
-- surrounding pipes needed for a one-column table:
|
||||
guard $ not (null rest && not openPipe)
|
||||
optional (char '|')
|
||||
blankline
|
||||
let cells = sequence (first:rest)
|
||||
|
|
|
@ -67,4 +67,12 @@
|
|||
,[[Plain [Str "orange"]]
|
||||
,[Plain [Str "17"]]]
|
||||
,[[Plain [Str "pear"]]
|
||||
,[Plain [Str "302"]]]]]
|
||||
,[Plain [Str "302"]]]]
|
||||
,Para [Str "One-column:"]
|
||||
,Table [] [AlignDefault] [0.0]
|
||||
[[Plain [Str "hi"]]]
|
||||
[[[Plain [Str "lo"]]]]
|
||||
,Para [Str "Header-less",Space,Str "one-column:"]
|
||||
,Table [] [AlignCenter] [0.0]
|
||||
[[]]
|
||||
[[[Plain [Str "hi"]]]]]
|
||||
|
|
|
@ -40,3 +40,13 @@ apple | 5
|
|||
orange| 17
|
||||
pear | 302
|
||||
|
||||
One-column:
|
||||
|
||||
|hi|
|
||||
|--|
|
||||
|lo|
|
||||
|
||||
Header-less one-column:
|
||||
|
||||
|:-:|
|
||||
|hi|
|
||||
|
|
Loading…
Add table
Reference in a new issue