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
This commit is contained in:
fiddlosopher 2007-03-10 17:48:16 +00:00
parent 0ce965f34c
commit 5ec31cc727

View file

@ -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
--