From fcb91e8e51808450c1bc5e8c1a72a0f7782c6270 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Tue, 28 Aug 2007 22:41:05 +0000 Subject: Rewrote link parsers for greater efficiency. git-svn-id: https://pandoc.googlecode.com/svn/trunk@945 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 2336c430f..93806f18f 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -818,23 +818,20 @@ title = choice [ titleWith '(' ')', titleWith '"' '"', titleWith '\'' '\''] "title" -link = choice [explicitLink, referenceLink] "link" - -explicitLink = try $ do +link = try $ do label <- reference - src <- source + src <- source <|> referenceLink label return $ Link label src -- a link like [this][ref] or [this][] or [this] -referenceLink = try $ do - label <- reference +referenceLink label = do ref <- option [] (try (skipSpaces >> optional newline >> skipSpaces >> reference)) let ref' = if null ref then label else ref state <- getState case lookupKeySrc (stateKeys state) ref' of Nothing -> fail "no corresponding key" - Just target -> return (Link label target) + Just target -> return target autoLink = autoLinkEmail <|> autoLinkRegular -- cgit v1.2.3