From 7bf7aba7e7a1f56e59ac90ea36496ea87b381333 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sun, 11 Mar 2007 07:56:29 +0000 Subject: Changes to Markdown reader relating to definition lists: + fixed bug in indentSpaces (which didn't properly handle cases with mixed spaces and tabs) + rewrote definition list code to conform to new syntax + include definition lists in list block + failIfStrict on definition lists git-svn-id: https://pandoc.googlecode.com/svn/trunk@572 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 01fa4788d..1e3a1ac6c 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -105,8 +105,8 @@ skipEndline = option Space endline indentSpaces = do state <- getState let tabStop = stateTabStop state - count tabStop (char ' ') <|> - (do{nonindentSpaces; string "\t"}) "indentation" + try (count tabStop (char ' ')) <|> + (do{many (char ' '); string "\t"}) "indentation" nonindentSpaces = do state <- getState @@ -349,7 +349,7 @@ blockQuote = do -- list blocks -- -list = choice [ bulletList, orderedList ] "list" +list = choice [ bulletList, orderedList, definitionList ] "list" bulletListStart = try (do option ' ' newline -- if preceded by a Plain block in a list context @@ -443,13 +443,18 @@ definitionListItem = try $ do notFollowedBy blankline notFollowedBy' indentSpaces term <- manyTill inline newline - raw <- many1 defRawBlock + char ':' 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 raw) + setInput (concat (firstline:"\n":blanksAfterFirst:raw)) contents <- parseBlocks setInput rest updateState (\st -> st {stateParserContext = oldContext}) @@ -461,6 +466,7 @@ defRawBlock = try $ do return $ (unlines rawlines) ++ trailing definitionList = do + failIfStrict items <- many1 definitionListItem let (terms, defs) = unzip items let defs' = compactify defs -- cgit v1.2.3