git.iko.soy/typeable/pandoc
on master help sign in
Added parser for definition lists, derived from reStructuredText
5ec31ccfiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+32−3
@@ -271,7 +271,7 @@ rawLine = try (do
271 contents <- many1 nonEndline
271 contents <- many1 nonEndline
272 end <- option "" (do
272 end <- option "" (do
273 newline
273 newline
274− option "" indentSpaces
274+ option "" (try indentSpaces)
275 return "\n")
275 return "\n")
276 return (contents ++ end))
276 return (contents ++ end))
277
277
@@ -405,7 +405,7 @@ listContinuation start = try (do
405listContinuationLine start = try (do
405listContinuationLine start = try (do
406 notFollowedBy' blankline
406 notFollowedBy' blankline
407 notFollowedBy' start
407 notFollowedBy' start
408− option "" indentSpaces
408+ option "" (try indentSpaces)
409 result <- manyTill anyChar newline
409 result <- manyTill anyChar newline
410 return (result ++ "\n"))
410 return (result ++ "\n"))
411
411
@@ -421,7 +421,7 @@ listItem start = try (do
421 -- parse the extracted block, which may contain various block elements:
421 -- parse the extracted block, which may contain various block elements:
422 rest <- getInput
422 rest <- getInput
423 let raw = concat (first:continuations)
423 let raw = concat (first:continuations)
424− setInput $ raw
424+ setInput raw
425 contents <- parseBlocks
425 contents <- parseBlocks
426 setInput rest
426 setInput rest
427 updateState (\st -> st {stateParserContext = oldContext})
427 updateState (\st -> st {stateParserContext = oldContext})
@@ -437,6 +437,35 @@ bulletList = try (do
437 let items' = compactify items
437 let items' = compactify items
438 return (BulletList items'))
438 return (BulletList items'))
439
439
440+-- definition lists
441+
442+definitionListItem = try $ do
443+ notFollowedBy blankline
444+ notFollowedBy' indentSpaces
445+ term <- manyTill inline newline
446+ raw <- many1 defRawBlock
447+ state <- getState
448+ let oldContext = stateParserContext state
449+ setState $ state {stateParserContext = ListItemState}
450+ -- parse the extracted block, which may contain various block elements:
451+ rest <- getInput
452+ setInput (concat raw)
453+ contents <- parseBlocks
454+ setInput rest
455+ updateState (\st -> st {stateParserContext = oldContext})
456+ return ((normalizeSpaces term), contents)
457+
458+defRawBlock = try $ do
459+ indentSpaces
460+ first <- anyLine
461+ rest <- manyTill (do {option "" (try indentSpaces);
462+ anyLine}) blanklines
463+ return $ (unlines (first:rest)) ++ "\n"
464+
465+definitionList = do
466+ items <- many1 definitionListItem
467+ return $ DefinitionList items
468+
440--
469--
441-- paragraph block
470-- paragraph block
442--
471--