@@ -818,23 +818,20 @@ title = choice [ titleWith '(' ')',
818 titleWith '"' '"',
818 titleWith '"' '"',
819 titleWith '\'' '\''] <?> "title"
819 titleWith '\'' '\''] <?> "title"
821−link = choice [explicitLink, referenceLink] <?> "link"
821+link = try $ do
823−explicitLink = try $ do
824 label <- reference
822 label <- reference
825− src <- source
823+ src <- source <|> referenceLink label
826 return $ Link label src
824 return $ Link label src
828-- a link like [this][ref] or [this][] or [this]
826-- a link like [this][ref] or [this][] or [this]
829−referenceLink = try $ do
827+referenceLink label = do
831 ref <- option [] (try (skipSpaces >> optional newline >>
828 ref <- option [] (try (skipSpaces >> optional newline >>
832 skipSpaces >> reference))
829 skipSpaces >> reference))
833 let ref' = if null ref then label else ref
830 let ref' = if null ref then label else ref
834 state <- getState
831 state <- getState
835 case lookupKeySrc (stateKeys state) ref' of
832 case lookupKeySrc (stateKeys state) ref' of
836 Nothing -> fail "no corresponding key"
833 Nothing -> fail "no corresponding key"
837− Just target -> return (Link label target)
834+ Just target -> return target
839autoLink = autoLinkEmail <|> autoLinkRegular
836autoLink = autoLinkEmail <|> autoLinkRegular