X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki%2FParser.hs;h=e2e39261929c4fcd37ddde176b1c22f9ec36e59e;hb=b3c3f333cd48bc74eb33f0f21d56a9d1bc65e0ea;hp=0433612ba5746bcd98312f5993b6847831336717;hpb=dcfffa578c5dd6647a5be7d2074488a520dfcf2d;p=Rakka.git diff --git a/Rakka/Wiki/Parser.hs b/Rakka/Wiki/Parser.hs index 0433612..e2e3926 100644 --- a/Rakka/Wiki/Parser.hs +++ b/Rakka/Wiki/Parser.hs @@ -5,6 +5,7 @@ module Rakka.Wiki.Parser where import Data.Maybe +import Network.URI import Rakka.Wiki import Text.ParserCombinators.Parsec @@ -267,6 +268,7 @@ inlineElement cmdTypeOf , apostrophes cmdTypeOf , text , pageLink + , extLink , inlineCmd cmdTypeOf ] @@ -345,6 +347,20 @@ pageLink = do try (string "[[") "page link" +extLink :: Parser InlineElement +extLink = do char '[' + uriStr <- many1 (noneOf " \t]") + skipMany (oneOf " \t") + text <- option Nothing + (many1 (noneOf "]") >>= return . Just) + + case parseURI uriStr of + Just uri -> char ']' >> return (ExternalLink uri text) + Nothing -> pzero "absolute URI" + + "external link" + + inlineCmd :: CommandTypeOf -> Parser InlineElement inlineCmd cmdTypeOf = (try $ do (tagName, tagAttrs) <- openTag