X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=blobdiff_plain;f=Rakka%2FWiki%2FParser.hs;h=6e4edeb4bc5c604aab1f6e97c0080471c1ebeff4;hp=7e0c1a90b8517037a10db00011bf630cb9be5d72;hb=e43bb104a7313dd696b8bb8aa3bafff94706a187;hpb=126e9f3faff19add1fb3dea792ec10dc57c30f03 diff --git a/Rakka/Wiki/Parser.hs b/Rakka/Wiki/Parser.hs index 7e0c1a9..6e4edeb 100644 --- a/Rakka/Wiki/Parser.hs +++ b/Rakka/Wiki/Parser.hs @@ -73,16 +73,15 @@ horizontalLine = try ( do count 4 (char '-') listElement :: CommandTypeOf -> Parser BlockElement -listElement cmdTypeOf = listElement' [] >>= return . List +listElement cmdTypeOf = listElement' [] where - listElement' :: [Char] -> Parser ListElement + listElement' :: [Char] -> Parser BlockElement listElement' stack = do t <- oneOf "*#" ws xs <- items (stack ++ [t]) - return (ListElement (toType t) xs) + return (List (toType t) xs) - -- ListItem の終了條件は、 items :: [Char] -> Parser [ListItem] items stack = do xs <- many1 $ inlineElement cmdTypeOf nested <- option Nothing @@ -91,7 +90,7 @@ listElement cmdTypeOf = listElement' [] >>= return . List string stack listElement' stack >>= return . Just rest <- items stack - return $ (map Right xs ++ map Left (catMaybes [nested])) : rest + return $ (map Inline xs ++ map Block (catMaybes [nested])) : rest <|> (try $ do skipMany comment newline @@ -271,9 +270,9 @@ blockCmd cmdTypeOf undefinedCmdErr :: String -> BlockElement undefinedCmdErr name = Div [("class", "error")] - [ Paragraph [Text ("The command `" ++ name ++ "' is not defined. " ++ - "Make sure you haven't mistyped.") - ] + [ Block (Paragraph [Text ("The command `" ++ name ++ "' is not defined. " ++ + "Make sure you haven't mistyped.") + ]) ]