git.iko.soy/typeable/pandoc
on master help sign in
Rewrote link parsers for greater efficiency.
fcb91e8fiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+4−7
@@ -818,23 +818,20 @@ title = choice [ titleWith '(' ')',
818 titleWith '"' '"',
818 titleWith '"' '"',
819 titleWith '\'' '\''] <?> "title"
819 titleWith '\'' '\''] <?> "title"
820
820
821−link = choice [explicitLink, referenceLink] <?> "link"
821+link = try $ do
822−
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
827
825
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
830− label <- reference
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
838
835
839autoLink = autoLinkEmail <|> autoLinkRegular
836autoLink = autoLinkEmail <|> autoLinkRegular
840
837