<|>
listElement
<|>
+ definitionList
+ <|>
leadingSpaced
<|>
paragraph
)
<|>
return []
-{-
- items stack = do nested <- listElement' stack
- rest <- items stack
- return (Left nested : rest)
- <|>
- do xs <- many1 inlineElement
- rest <- items stack
- return (Right xs : rest)
- <|>
- try ( newline
- >>
- string stack
- >>
- items stack
- )
- <|>
- return []
--}
toType :: Char -> ListType
toType '*' = Bullet
toType '#' = Numbered
+definitionList :: Parser BlockElement
+definitionList = many1 definition >>= return . DefinitionList
+ where
+ definition :: Parser Definition
+ definition = do char ';'
+ ws
+ tHead <- inlineElement
+ tRest <- term
+ d <- description
+ return (Definition (tHead:tRest) d)
+ <?>
+ "definition list"
+
+ term :: Parser [InlineElement]
+ term = (char ':' >> ws >> return [])
+ <|>
+ (newline >> char ':' >> ws >> return [])
+ <|>
+ do x <- inlineElement
+ xs <- term
+ return (x:xs)
+ <?>
+ "term to be defined"
+
+ description :: Parser [InlineElement]
+ description = do x <- inlineElement
+ xs <- description
+ return (x:xs)
+ <|>
+ try ( do newline
+ char ':'
+ ws
+ xs <- description
+ return (Text "\n" : xs)
+ )
+ <|>
+ (newline >> return [])
+ <|>
+ (eof >> return [])
+ <?>
+ "description of term"
+
+
leadingSpaced :: Parser BlockElement
leadingSpaced = char ' ' >> leadingSpaced' >>= return . LeadingSpaced
where
text :: Parser InlineElement
-text = many1 (noneOf ('\n':inlineSymbols)) >>= return . Text
+text = ( char ':'
+ >>
+ many (noneOf ('\n':':':inlineSymbols))
+ >>=
+ return . Text . (':' :)
+ -- 定義リストとの關係上、コロンは先頭にしか存在できない。
+ )
+ <|>
+ ( many1 (noneOf ('\n':':':inlineSymbols))
+ >>=
+ return . Text
+ )
pageLink :: Parser InlineElement
blockSymbols :: [Char]
-blockSymbols = " =-*#"
+blockSymbols = " =-*#;"
inlineSymbols :: [Char]