git.iko.soy/typeable/pandoc
on master help sign in
Changed definition list syntax in markdown reader and simplified
cf08143fiddlosopher
README+7−8
@@ -435,21 +435,20 @@ Pandoc supports definition lists, using a syntax inspired by
435 Term 2
435 Term 2
436 : Definition 2
436 : Definition 2
437
437
438− Second paragraph of definition 2.
438+ : Second paragraph of definition 2.
439
439
440−The terms must fit on one line, but they may contain arbitrary inline
441−markup (emphasis, links, etc.). The definition must begin on the line
440+Each term must fit on one line. The definition must begin on the line
442−after the term, and must begin with a colon. The definition consists of
441+after the term. The definition consists of one or more block elements
443−one or more block elements (paragraph, code block, list, etc.).
442+(paragraph, code block, list, etc.), each beginning with a colon and
444−Each block must be indented one tab stop.
443+(aside from the colon) indented one tab stop.
445
444
446 Term *with inline markup*
445 Term *with inline markup*
447 : Here is the definition. It may
446 : Here is the definition. It may
448 contain multiple blocks. Here is some code:
447 contain multiple blocks. Here is some code:
449
448
450− {* my code *}
449+ : {* my code *}
451
450
452− Here is the third paragraph of this definition.
451+ : Here is the third paragraph of this definition.
453
452
454If you leave space after the definition (as in the first example above),
453If you leave space after the definition (as in the first example above),
455the definitions will be considered paragraphs. In some output formats,
454the definitions will be considered paragraphs. In some output formats,
src/Text/Pandoc/Readers/Markdown.hs+9−10
@@ -456,27 +456,26 @@ definitionListItem = try $ do
456 notFollowedBy blankline
456 notFollowedBy blankline
457 notFollowedBy' indentSpaces
457 notFollowedBy' indentSpaces
458 term <- manyTill inline newline
458 term <- manyTill inline newline
459− char ':'
459+ raw <- many1 defRawBlock
460 state <- getState
460 state <- getState
461− let tabStop = stateTabStop state
462− try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"})
463− firstline <- anyLine
464− blanksAfterFirst <- option "" blanklines
465− raw <- many defRawBlock
466 let oldContext = stateParserContext state
461 let oldContext = stateParserContext state
467− setState $ state {stateParserContext = ListItemState}
468 -- parse the extracted block, which may contain various block elements:
462 -- parse the extracted block, which may contain various block elements:
469 rest <- getInput
463 rest <- getInput
470− setInput (concat (firstline:"\n":blanksAfterFirst:raw))
464+ setInput (concat raw)
471 contents <- parseBlocks
465 contents <- parseBlocks
472 setInput rest
466 setInput rest
473 updateState (\st -> st {stateParserContext = oldContext})
467 updateState (\st -> st {stateParserContext = oldContext})
474 return ((normalizeSpaces term), contents)
468 return ((normalizeSpaces term), contents)
475
469
476defRawBlock = try $ do
470defRawBlock = try $ do
471+ char ':'
472+ state <- getState
473+ let tabStop = stateTabStop state
474+ try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"})
475+ firstline <- anyLine
477− rawlines <- many1 (do {notFollowedBy' blankline; indentSpaces; anyLine})
476+ rawlines <- many (do {notFollowedBy' blankline; indentSpaces; anyLine})
478 trailing <- option "" blanklines
477 trailing <- option "" blanklines
479− return $ (unlines rawlines) ++ trailing
478+ return $ firstline ++ "\n" ++ unlines rawlines ++ trailing
480
479
481definitionList = do
480definitionList = do
482 failIfStrict
481 failIfStrict