aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-03-10 17:48:16 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-03-10 17:48:16 +0000
commit5ec31cc7278acb102fa444b9f8f92e8bb442d21f (patch)
tree07ad492d3dd096e3c63bcc0d5ed75b40a409fb06 /src/Text/Pandoc/Readers
parent0ce965f34c0caf70e9a6a7b88508beec1e617fbb (diff)
downloadpandoc-5ec31cc7278acb102fa444b9f8f92e8bb442d21f.tar.gz
Added parser for definition lists, derived from reStructuredText
syntax: term 1 Definition 1 Paragraph 2 of definition 1. term 2 There must be whitespace between entries. Any kind of block may serve as a definition, but the first line of each block must be indented. terms can contain any *inline* elements If you want to be lazy, you can just indent the first line of the definition block. git-svn-id: https://pandoc.googlecode.com/svn/trunk@566 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index df41e1dd6..70a94fb2c 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -271,7 +271,7 @@ rawLine = try (do
contents <- many1 nonEndline
end <- option "" (do
newline
- option "" indentSpaces
+ option "" (try indentSpaces)
return "\n")
return (contents ++ end))
@@ -405,7 +405,7 @@ listContinuation start = try (do
listContinuationLine start = try (do
notFollowedBy' blankline
notFollowedBy' start
- option "" indentSpaces
+ option "" (try indentSpaces)
result <- manyTill anyChar newline
return (result ++ "\n"))
@@ -421,7 +421,7 @@ listItem start = try (do
-- parse the extracted block, which may contain various block elements:
rest <- getInput
let raw = concat (first:continuations)
- setInput $ raw
+ setInput raw
contents <- parseBlocks
setInput rest
updateState (\st -> st {stateParserContext = oldContext})
@@ -437,6 +437,35 @@ bulletList = try (do
let items' = compactify items
return (BulletList items'))
+-- definition lists
+
+definitionListItem = try $ do
+ notFollowedBy blankline
+ notFollowedBy' indentSpaces
+ term <- manyTill inline newline
+ raw <- many1 defRawBlock
+ state <- getState
+ let oldContext = stateParserContext state
+ setState $ state {stateParserContext = ListItemState}
+ -- parse the extracted block, which may contain various block elements:
+ rest <- getInput
+ setInput (concat raw)
+ contents <- parseBlocks
+ setInput rest
+ updateState (\st -> st {stateParserContext = oldContext})
+ return ((normalizeSpaces term), contents)
+
+defRawBlock = try $ do
+ indentSpaces
+ first <- anyLine
+ rest <- manyTill (do {option "" (try indentSpaces);
+ anyLine}) blanklines
+ return $ (unlines (first:rest)) ++ "\n"
+
+definitionList = do
+ items <- many1 definitionListItem
+ return $ DefinitionList items
+
--
-- paragraph block
--