From 84aa875bdba3215cf79f195a3f2ba6db06498257 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Mon, 20 Aug 2007 18:52:49 +0000 Subject: Changes to Markdown reader for better conformity to the Markdown test suite under --strict: + Removed check for a following setext header in endline. A full test is too inefficient (doubles benchmark time), and the substitute we had before is not 100% accurate. + Don't use Code elements for autolinks if --strict specified. git-svn-id: https://pandoc.googlecode.com/svn/trunk@876 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index f4b97527f..5f0c0b7a5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -322,7 +322,7 @@ bulletListStart = try $ do skipSpaces anyOrderedListStart = try $ do - optional newline -- if preceded by a Plain block in a list context + optional newline -- if preceded by a Plain block in a list context nonindentSpaces state <- getState if stateStrict state @@ -786,8 +786,6 @@ endline = try $ do then do notFollowedBy emailBlockQuoteStart notFollowedBy (char '#') -- atx header - notFollowedBy (manyTill anyChar newline >> oneOf setextHChars) - -- setext header else return () -- parse potential list-starts differently if in a list: if stateParserContext st == ListItemState @@ -854,9 +852,10 @@ autoLinkEmail = try $ do char '<' name <- many1Till (noneOf "/:<> \t\n") (char '@') domain <- sepBy1 (many1 (noneOf "/:.@<> \t\n")) (char '.') - let src = name ++ "@" ++ (joinWithSep "." domain) char '>' - return $ Link [Code src] (("mailto:" ++ src), "") + let src = name ++ "@" ++ (joinWithSep "." domain) + txt <- autoLinkText src + return $ Link txt (("mailto:" ++ src), "") -- a link autoLinkRegular = try $ do @@ -864,7 +863,14 @@ autoLinkRegular = try $ do prot <- oneOfStrings ["http:", "ftp:", "mailto:"] rest <- many1Till (noneOf " \t\n<>") (char '>') let src = prot ++ rest - return $ Link [Code src] (src, "") + txt <- autoLinkText src + return $ Link txt (src, "") + +autoLinkText src = do + st <- getState + return $ if stateStrict st + then [Str src] + else [Code src] image = try $ do char '!' -- cgit v1.2.3