@@ -31,7 +31,7 @@ module Text.Pandoc.Readers.Markdown (
3131 readMarkdown
3232 ) where
3333
34−import Data.List ( findIndex, sortBy, transpose )
34+import Data.List ( findIndex, sortBy, transpose, isSuffixOf, intersect )
3535import Data.Char ( isAlphaNum )
3636import Text.ParserCombinators.Pandoc
3737import Text.Pandoc.Definition
@@ -43,7 +43,6 @@ import Text.Pandoc.Readers.HTML ( rawHtmlBlock,
4343 htmlEndTag, extractTagType,
4444 htmlBlockElement )
4545import Text.Pandoc.Entities ( decodeEntities )
46−import Text.Regex ( matchRegex, mkRegex )
4746import Text.ParserCombinators.Parsec
4847
4948-- | Read markdown from an input string and return a Pandoc document.
@@ -474,14 +473,13 @@ htmlBlock = do
474473 else rawHtmlBlocks
475474
476475-- True if tag is self-closing
477−selfClosing tag = case (matchRegex (mkRegex "\\/[[:space:]]*>$") tag) of
478− Just _ -> True
479− Nothing -> False
476+isSelfClosing tag =
477+ isSuffixOf "/>" $ filter (\c -> (not (c `elem` " \n\t"))) tag
480478
481479strictHtmlBlock = try (do
482480 tag <- anyHtmlBlockTag
483481 let tag' = extractTagType tag
484− if selfClosing tag || tag' == "hr"
482+ if isSelfClosing tag || tag' == "hr"
485483 then return tag
486484 else do
487485 contents <- many (do{notFollowedBy' (htmlEndTag tag');
@@ -930,17 +928,24 @@ referenceLinkSingle = try (do
930928 else fail "no corresponding key"
931929 return (Link label (Ref label)))
932930
933−-- a link <like.this.com>
934−autoLink = try (do
931+autoLink = do
935932 notFollowedBy' (anyHtmlTag <|> anyHtmlEndTag)
933+ autoLinkEmail <|> autoLinkRegular
934+
935+-- a link <like@this.com>
936+autoLinkEmail = try $ do
937+ char autoLinkStart
938+ name <- many1Till (noneOf "/:<> \t\n") (char '@')
939+ domain <- sepBy1 (many1 (noneOf "/:.@<> \t\n")) (char '.')
940+ let src = name ++ "@" ++ (joinWithSep "." domain)
941+ char autoLinkEnd
942+ return $ Link [Str src] (Src ("mailto:" ++ src) "")
943+
944+-- a link <like.this.com>
945+autoLinkRegular = try $ do
936946 src <- between (char autoLinkStart) (char autoLinkEnd)
937947 (many (noneOf (spaceChars ++ endLineChars ++ [autoLinkEnd])))
938− case (matchRegex emailAddress src) of
939− Just _ -> return (Link [Str src] (Src ("mailto:" ++ src) ""))
940− Nothing -> return (Link [Str src] (Src src "")))
941−
942−emailAddress =
943− mkRegex "([^@:/]+)@(([^.]+[.]?)*([^.]+))" -- presupposes no whitespace
948+ return $ Link [Str src] (Src src "")
944949
945950image = try (do
946951 char imageStart