git.iko.soy/typeable/pandoc
on master help sign in
Changed definition list syntax in markdown reader and simplified

the parsing code. A colon is now required before every block in a definition. This fixes a problem with the old syntax, in which the last block in the following was ambiguous between a regular paragraph in the definition and a code block following the definition list: term : definition is this code or more definition? git-svn-id: https://pandoc.googlecode.com/svn/trunk@589 788f1e2b-df1e-0410-8736-df70ead52e1b

commitcf081435ff00004188f584b180fc66d8e4fe7a57 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 3 May 2007, 14:42 (19 years ago) parent485fa81
2 files changed+16−18
README+7−8 src/Text/Pandoc/Readers/Markdown.hs+9−10
README+7−8
@@ -435,21 +435,20 @@ Pandoc supports definition lists, using a syntax inspired by
435435 Term 2
436436 : Definition 2
437437
438− Second paragraph of definition 2.
438+ : Second paragraph of definition 2.
439439
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
442−after the term, and must begin with a colon. The definition consists of
443−one or more block elements (paragraph, code block, list, etc.).
444−Each block must be indented one tab stop.
440+Each term must fit on one line. The definition must begin on the line
441+after the term. The definition consists of one or more block elements
442+(paragraph, code block, list, etc.), each beginning with a colon and
443+(aside from the colon) indented one tab stop.
445444
446445 Term *with inline markup*
447446 : Here is the definition. It may
448447 contain multiple blocks. Here is some code:
449448
450− {* my code *}
449+ : {* my code *}
451450
452− Here is the third paragraph of this definition.
451+ : Here is the third paragraph of this definition.
453452
454453If you leave space after the definition (as in the first example above),
455454the definitions will be considered paragraphs. In some output formats,
src/Text/Pandoc/Readers/Markdown.hs+9−10
@@ -456,27 +456,26 @@ definitionListItem = try $ do
456456 notFollowedBy blankline
457457 notFollowedBy' indentSpaces
458458 term <- manyTill inline newline
459− char ':'
459+ raw <- many1 defRawBlock
460460 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
466461 let oldContext = stateParserContext state
467− setState $ state {stateParserContext = ListItemState}
468462 -- parse the extracted block, which may contain various block elements:
469463 rest <- getInput
470− setInput (concat (firstline:"\n":blanksAfterFirst:raw))
464+ setInput (concat raw)
471465 contents <- parseBlocks
472466 setInput rest
473467 updateState (\st -> st {stateParserContext = oldContext})
474468 return ((normalizeSpaces term), contents)
475469
476470defRawBlock = try $ do
477− rawlines <- many1 (do {notFollowedBy' blankline; indentSpaces; anyLine})
471+ char ':'
472+ state <- getState
473+ let tabStop = stateTabStop state
474+ try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"})
475+ firstline <- anyLine
476+ rawlines <- many (do {notFollowedBy' blankline; indentSpaces; anyLine})
478477 trailing <- option "" blanklines
479− return $ (unlines rawlines) ++ trailing
478+ return $ firstline ++ "\n" ++ unlines rawlines ++ trailing
480479
481480definitionList = do
482481 failIfStrict