aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-01-15 12:44:50 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2013-01-15 12:44:50 -0800
commitbf3a911a1c3421424ba4d5a0ac3a7f8e494d715a (patch)
tree347cd8a1af94ce116c7fe4d215dedfe2923ad9be /src
parente9b3d5aa7a3095a5ad7a4d5ec3e5bb958a97fa50 (diff)
downloadpandoc-bf3a911a1c3421424ba4d5a0ac3a7f8e494d715a.tar.gz
Changed Ext_autolink_urls -> Ext_autolink_bare_uris.
Added tests.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Options.hs4
-rw-r--r--src/Text/Pandoc/Parsing.hs7
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs2
3 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index e63b328a3..0471161e0 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -76,7 +76,7 @@ data Extension =
| Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
-- iff container has attribute 'markdown'
| Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
- | Ext_autolink_urls -- ^ Make all absolute URLs into links
+ | Ext_autolink_bare_uris -- ^ Make all absolute URIs into links
| Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters
| Ext_startnum -- ^ Make start number of ordered list significant
| Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php
@@ -159,7 +159,7 @@ githubMarkdownExtensions = Set.fromList
, Ext_fenced_code_blocks
, Ext_fenced_code_attributes
, Ext_backtick_code_blocks
- , Ext_autolink_urls
+ , Ext_autolink_bare_uris
, Ext_intraword_underscores
, Ext_strikeout
, Ext_hard_line_breaks
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 1bc0e689a..26e8c2325 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -212,7 +212,7 @@ notFollowedBy' p = try $ join $ do a <- try p
-- (This version due to Andrew Pimlott on the Haskell mailing list.)
oneOfStrings' :: (Char -> Char -> Bool) -> [String] -> Parser [Char] st String
-oneOfStrings' matches [] = fail "no strings"
+oneOfStrings' _ [] = fail "no strings"
oneOfStrings' matches strs = try $ do
c <- anyChar
let strs' = [xs | (x:xs) <- strs, x `matches` c]
@@ -392,10 +392,13 @@ schemes = ["coap","doi","javascript","aaa","aaas","about","acap","cap","cid",
"ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri",
"ymsgr"]
+uriScheme :: Parser [Char] st String
+uriScheme = oneOfStringsCI schemes
+
-- | Parses a URI. Returns pair of original and URI-escaped version.
uri :: Parser [Char] st (String, String)
uri = try $ do
- scheme <- oneOfStringsCI schemes
+ scheme <- uriScheme
char ':'
-- /^[\/\w\u0080-\uffff]+|%[A-Fa-f0-9]+|&#?\w+;|(?:[,]+|[\S])[%&~\w\u0080-\uffff]/
-- We allow punctuation except at the end, since
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 156062099..8141187e7 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1543,7 +1543,7 @@ referenceLink constructor (lab, raw) = do
bareURL :: MarkdownParser (F Inlines)
bareURL = try $ do
- guardEnabled Ext_autolink_urls
+ guardEnabled Ext_autolink_bare_uris
(orig, src) <- uri <|> emailAddress
return $ return $ B.link src "" (B.str orig)