where
import Data.Maybe
+import Network.URI
import Rakka.Wiki
import Text.ParserCombinators.Parsec
, apostrophes cmdTypeOf
, text
, pageLink
+ , extLink
, inlineCmd cmdTypeOf
]
"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