diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-28 22:41:05 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-28 22:41:05 +0000 |
commit | fcb91e8e51808450c1bc5e8c1a72a0f7782c6270 (patch) | |
tree | abfa4b087f48189f2ca2c602df4e16655ec94e06 /src | |
parent | e407279b35e24fc5e0472cfba2c07fc2373aacfb (diff) | |
download | pandoc-fcb91e8e51808450c1bc5e8c1a72a0f7782c6270.tar.gz |
Rewrote link parsers for greater efficiency.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@945 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 11 |
1 files changed, 4 insertions, 7 deletions
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 |