From cf081435ff00004188f584b180fc66d8e4fe7a57 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 3 May 2007 14:42:40 +0000 Subject: 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 --- src/Text/Pandoc/Readers/Markdown.hs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index b6acce62b..05a958090 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -456,27 +456,26 @@ definitionListItem = try $ do notFollowedBy blankline notFollowedBy' indentSpaces term <- manyTill inline newline - char ':' + raw <- many1 defRawBlock state <- getState - let tabStop = stateTabStop state - try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"}) - firstline <- anyLine - blanksAfterFirst <- option "" blanklines - raw <- many defRawBlock let oldContext = stateParserContext state - setState $ state {stateParserContext = ListItemState} -- parse the extracted block, which may contain various block elements: rest <- getInput - setInput (concat (firstline:"\n":blanksAfterFirst:raw)) + setInput (concat raw) contents <- parseBlocks setInput rest updateState (\st -> st {stateParserContext = oldContext}) return ((normalizeSpaces term), contents) defRawBlock = try $ do - rawlines <- many1 (do {notFollowedBy' blankline; indentSpaces; anyLine}) + char ':' + state <- getState + let tabStop = stateTabStop state + try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"}) + firstline <- anyLine + rawlines <- many (do {notFollowedBy' blankline; indentSpaces; anyLine}) trailing <- option "" blanklines - return $ (unlines rawlines) ++ trailing + return $ firstline ++ "\n" ++ unlines rawlines ++ trailing definitionList = do failIfStrict -- cgit v1.2.3