From 8f9c51474f8cad8cd2337f9231d95fd8e7f7e258 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 5 Nov 2017 07:55:04 +0300 Subject: Allow to set document types explicitly --- Pancake/Command.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Pancake/Command.hs') diff --git a/Pancake/Command.hs b/Pancake/Command.hs index 46a3e66..a1a0b09 100644 --- a/Pancake/Command.hs +++ b/Pancake/Command.hs @@ -23,7 +23,8 @@ import Pancake.Configuration data Command = Quit | Follow Int | More - | GoTo URI + | GoTo (Maybe String) URI + -- ^ Document type, URI | Reload | Back | Forward @@ -61,8 +62,9 @@ showRef = char '?' *> (Show . read <$> many1 digit) <* eof -- | 'GoTo' command parser. goTo :: Parser Command goTo = do - s <- manyTill anyChar eof - maybe (fail "Failed to parse URI") (pure . GoTo) $ parseURIReference s + f <- optionMaybe (try (many1 alphaNum <* space)) "type" + s <- manyTill anyChar eof "URI" + maybe (fail "Failed to parse URI") (pure . GoTo f) $ parseURIReference s -- | 'Shortcut' command parser. shortcut :: M.Map String String -> Parser Command -- cgit v1.2.3