aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-03-11 07:56:29 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-03-11 07:56:29 +0000
commit7bf7aba7e7a1f56e59ac90ea36496ea87b381333 (patch)
treea047ba3949ff3ba53b88d3b2d2de84f70a5a3ff4 /src/Text/Pandoc/Readers
parentaca046702e68c75551072a49a615d49cc5887eb3 (diff)
downloadpandoc-7bf7aba7e7a1f56e59ac90ea36496ea87b381333.tar.gz
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
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs16
1 files changed, 11 insertions, 5 deletions
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