x <- notFollowedBy (char '=') >> anyChar
xs <- manyTill anyChar (try $ ws >> ( count n (char '=')
<?>
- ("trailing " ++ take n (repeat '='))
+ ("trailing " ++ replicate n '=')
)
)
ws
$ try $ do skipMany comment
newline
string stack
- listElement' stack >>= return . Just
+ liftM Just (listElement' stack)
rest <- items stack
return $ (map Inline xs ++ map Block (catMaybes [nested])) : rest
<|>
definitionList :: CommandTypeOf -> Parser BlockElement
-definitionList cmdTypeOf = many1 definition >>= return . DefinitionList
+definitionList cmdTypeOf = liftM DefinitionList (many1 definition)
where
definition :: Parser Definition
definition = do char ';'
leadingSpaced :: CommandTypeOf -> Parser BlockElement
-leadingSpaced cmdTypeOf = (char ' ' >> leadingSpaced' >>= return . Preformatted)
+leadingSpaced cmdTypeOf = liftM Preformatted (char ' ' >> leadingSpaced')
<?>
"leading space"
where
xs <- leadingSpaced'
return (x:xs)
<|>
- try ( newline
- >>
- char ' '
- >>
- leadingSpaced'
- >>=
- return . (Text "\n" :)
+ try ( liftM (Text "\n" :) ( newline
+ >>
+ char ' '
+ >>
+ leadingSpaced'
+ )
)
<|>
return []
paragraph :: CommandTypeOf -> Parser BlockElement
-paragraph cmdTypeOf = paragraph' >>= return . Paragraph
+paragraph cmdTypeOf = liftM Paragraph paragraph'
where
paragraph' :: Parser [InlineElement]
paragraph' = do x <- inlineElement cmdTypeOf
Just BlockCommandType
-> do xs <- contents
closeTag tagName
- return $ BlockCmd $ BlockCommand {
+ return $ BlockCmd BlockCommand {
bCmdName = tagName
, bCmdAttributes = tagAttrs
, bCmdContents = xs
(try $ do (tagName, tagAttrs) <- emptyTag
case cmdTypeOf tagName of
Just BlockCommandType
- -> return $ BlockCmd $ BlockCommand {
+ -> return $ BlockCmd BlockCommand {
bCmdName = tagName
, bCmdAttributes = tagAttrs
, bCmdContents = []
nowiki :: Parser InlineElement
-nowiki = try (string "<!nowiki[") >> nowiki' >>= return . Text
+nowiki = liftM Text (try (string "<!nowiki[") >> nowiki')
where
nowiki' :: Parser String
nowiki' = do try (string "]>")
text :: Parser InlineElement
-text = ( char ':'
- >>
- many (noneOf ('\n':inlineSymbols))
- >>=
- return . Text . (':' :)
- -- 定義リストとの關係上、コロンは先頭にしか來れない。
- )
+text = liftM (Text . (':' :)) ( char ':'
+ >>
+ many (noneOf ('\n':inlineSymbols))
+ )
+ -- 定義リストとの關係上、コロンは先頭にしか來られない。
<|>
- ( many1 (noneOf ('\n':inlineSymbols))
- >>=
- return . Text
- )
+ liftM Text (many1 (noneOf ('\n':inlineSymbols)))
<?>
"text"
objLink = do try (string "[[[")
page <- many1 (noneOf "|]")
label <- option Nothing
- (char '|' >> many1 (satisfy (/= ']')) >>= return . Just)
+ (liftM Just (char '|' >> many1 (satisfy (/= ']'))))
string "]]]"
return $ ObjectLink page label
<?>
pageLink :: Parser InlineElement
pageLink = do try (string "[[")
page <- option Nothing
- (many1 (noneOf "#|]") >>= return . Just)
+ (liftM Just (many1 (noneOf "#|]")))
fragment <- option Nothing
- (char '#' >> many1 (noneOf "|]") >>= return . Just)
+ (liftM Just (char '#' >> many1 (noneOf "|]")))
label <- option Nothing
- (char '|' >> many1 (satisfy (/= ']')) >>= return . Just)
+ (liftM Just (char '|' >> many1 (satisfy (/= ']'))))
case (page, fragment) of
(Nothing, Nothing) -> pzero
uriStr <- many1 (noneOf " \t]")
skipMany (oneOf " \t")
label <- option Nothing
- (many1 (noneOf "]") >>= return . Just)
+ (liftM Just (many1 (noneOf "]")))
case parseURI uriStr of
Just uri -> char ']' >> return (ExternalLink uri label)
Just InlineCommandType
-> do xs <- contents
closeTag tagName
- return $ InlineCmd $ InlineCommand {
+ return $ InlineCmd InlineCommand {
iCmdName = tagName
, iCmdAttributes = tagAttrs
, iCmdContents = xs
(try $ do (tagName, tagAttrs) <- emptyTag
case cmdTypeOf tagName of
Just InlineCommandType
- -> return $ InlineCmd $ InlineCommand {
+ -> return $ InlineCmd InlineCommand {
iCmdName = tagName
, iCmdAttributes = tagAttrs
, iCmdContents = []
<|>
(comment >> contents)
<|>
- (newline >> contents >>= return . (Text "\n" :))
+ liftM (Text "\n" :) (newline >> contents)
<|>
return []
"comment"
where
skipTillEnd :: Int -> Parser ()
- skipTillEnd level = ( (try (string "<!--") >> skipTillEnd (level + 1))
- <|>
- (try (string "-->") >> case level of
- 1 -> return ()
- n -> skipTillEnd (n - 1))
- <|>
- (anyChar >> skipTillEnd level)
- )
+ skipTillEnd level = (try (string "<!--") >> skipTillEnd (level + 1))
+ <|>
+ (try (string "-->") >> case level of
+ 1 -> return ()
+ n -> skipTillEnd (n - 1))
+ <|>
+ (anyChar >> skipTillEnd level)
blockSymbols :: [Char]
-- end of line
eol :: Parser ()
-eol = ( (newline >> return ())
- <|>
- eof
- )
+eol = (newline >> return ())
+ <|>
+ eof