git.iko.soy/typeable/pandoc
on master help sign in
Changes to Markdown reader relating to definition lists:
7bf7abafiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+11−5
@@ -105,8 +105,8 @@ skipEndline = option Space endline
105indentSpaces = do
105indentSpaces = do
106 state <- getState
106 state <- getState
107 let tabStop = stateTabStop state
107 let tabStop = stateTabStop state
108− count tabStop (char ' ') <|>
108+ try (count tabStop (char ' ')) <|>
109− (do{nonindentSpaces; string "\t"}) <?> "indentation"
109+ (do{many (char ' '); string "\t"}) <?> "indentation"
110
110
111nonindentSpaces = do
111nonindentSpaces = do
112 state <- getState
112 state <- getState
@@ -349,7 +349,7 @@ blockQuote = do
349-- list blocks
349-- list blocks
350--
350--
351
351
352−list = choice [ bulletList, orderedList ] <?> "list"
352+list = choice [ bulletList, orderedList, definitionList ] <?> "list"
353
353
354bulletListStart = try (do
354bulletListStart = try (do
355 option ' ' newline -- if preceded by a Plain block in a list context
355 option ' ' newline -- if preceded by a Plain block in a list context
@@ -443,13 +443,18 @@ definitionListItem = try $ do
443 notFollowedBy blankline
443 notFollowedBy blankline
444 notFollowedBy' indentSpaces
444 notFollowedBy' indentSpaces
445 term <- manyTill inline newline
445 term <- manyTill inline newline
446− raw <- many1 defRawBlock
446+ char ':'
447 state <- getState
447 state <- getState
448+ let tabStop = stateTabStop state
449+ try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"})
450+ firstline <- anyLine
451+ blanksAfterFirst <- option "" blanklines
452+ raw <- many defRawBlock
448 let oldContext = stateParserContext state
453 let oldContext = stateParserContext state
449 setState $ state {stateParserContext = ListItemState}
454 setState $ state {stateParserContext = ListItemState}
450 -- parse the extracted block, which may contain various block elements:
455 -- parse the extracted block, which may contain various block elements:
451 rest <- getInput
456 rest <- getInput
452− setInput (concat raw)
457+ setInput (concat (firstline:"\n":blanksAfterFirst:raw))
453 contents <- parseBlocks
458 contents <- parseBlocks
454 setInput rest
459 setInput rest
455 updateState (\st -> st {stateParserContext = oldContext})
460 updateState (\st -> st {stateParserContext = oldContext})
@@ -461,6 +466,7 @@ defRawBlock = try $ do
461 return $ (unlines rawlines) ++ trailing
466 return $ (unlines rawlines) ++ trailing
462
467
463definitionList = do
468definitionList = do
469+ failIfStrict
464 items <- many1 definitionListItem
470 items <- many1 definitionListItem
465 let (terms, defs) = unzip items
471 let (terms, defs) = unzip items
466 let defs' = compactify defs
472 let defs' = compactify defs