From: Michael Andreen Date: Mon, 7 Feb 2005 08:40:36 +0000 (+0000) Subject: cleanup in the eol code X-Git-Url: https://ruin.nu/git/?p=yawbih.git;a=commitdiff_plain;h=5d62f948d470010c1f7eb855f7cad681253f315a cleanup in the eol code --- diff --git a/Wiki.hs b/Wiki.hs index 210708d..5e75da1 100644 --- a/Wiki.hs +++ b/Wiki.hs @@ -50,8 +50,13 @@ type Document = [Markup] wikiParser :: Parser Document wikiParser = many1 pMain +firstInLineChars = "#*=" + pPara :: Parser Markup -pPara = count 2 pEol >> return (Paragraph) +pPara = do + count 2 pEol + notFollowedBy $ oneOf firstInLineChars + return (Paragraph) pLink :: Parser Markup pLink = do @@ -68,16 +73,21 @@ pList enum = do pListItem :: Bool -> Parser [Markup] pListItem enum = do - many1 pEol + pEol char $ listToken enum - many pOneLine + many (pOneLine <|> try (pOneEol)) + +pOneEol = do + c <- pEol + notFollowedBy (oneOf $ firstInLineChars++"\r\n") + return c listToken True = '#' listToken False = '*' pHeading :: Parser Markup pHeading = do - many1 pEol + pEol level <- many1 $ char '=' s <- pStopAt level return (Heading (length level) s)