git.iko.soy/typeable/pandoc
on master help sign in
Changed Ext_autolink_urls -> Ext_autolink_bare_uris.

Added tests.

commitbf3a911a1c3421424ba4d5a0ac3a7f8e494d715a authorJohn MacFarlane <jgm@berkeley.edu> dateTue 15 Jan 2013, 12:44 (14 years ago) parente9b3d5a
5 files changed+11−8
README+2−2 src/Text/Pandoc/Options.hs+2−2 src/Text/Pandoc/Parsing.hs+5−2 src/Text/Pandoc/Readers/Markdown.hs+1−1 tests/Tests/Readers/Markdown.hs+1−1
README+2−2
@@ -2342,8 +2342,8 @@ Note that the pandoc document model does not support
23422342abbreviations, so if this extension is enabled, abbreviation keys are
23432343simply skipped (as opposed to being parsed as paragraphs).
23442344
2345−**Extension: `autolink_urls`**\
2346−Makes all absolute URLs into links, even when not surrounded by
2345+**Extension: `autolink_bare_uris`**\
2346+Makes all absolute URIs into links, even when not surrounded by
23472347pointy braces `<...>`.
23482348
23492349Producing slide shows with Pandoc
src/Text/Pandoc/Options.hs+2−2
@@ -76,7 +76,7 @@ data Extension =
7676 | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
7777 -- iff container has attribute 'markdown'
7878 | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
79− | Ext_autolink_urls -- ^ Make all absolute URLs into links
79+ | Ext_autolink_bare_uris -- ^ Make all absolute URIs into links
8080 | Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters
8181 | Ext_startnum -- ^ Make start number of ordered list significant
8282 | Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php
@@ -159,7 +159,7 @@ githubMarkdownExtensions = Set.fromList
159159 , Ext_fenced_code_blocks
160160 , Ext_fenced_code_attributes
161161 , Ext_backtick_code_blocks
162− , Ext_autolink_urls
162+ , Ext_autolink_bare_uris
163163 , Ext_intraword_underscores
164164 , Ext_strikeout
165165 , Ext_hard_line_breaks
src/Text/Pandoc/Parsing.hs+5−2
@@ -212,7 +212,7 @@ notFollowedBy' p = try $ join $ do a <- try p
212212-- (This version due to Andrew Pimlott on the Haskell mailing list.)
213213
214214oneOfStrings' :: (Char -> Char -> Bool) -> [String] -> Parser [Char] st String
215−oneOfStrings' matches [] = fail "no strings"
215+oneOfStrings' _ [] = fail "no strings"
216216oneOfStrings' matches strs = try $ do
217217 c <- anyChar
218218 let strs' = [xs | (x:xs) <- strs, x `matches` c]
@@ -392,10 +392,13 @@ schemes = ["coap","doi","javascript","aaa","aaas","about","acap","cap","cid",
392392 "ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri",
393393 "ymsgr"]
394394
395+uriScheme :: Parser [Char] st String
396+uriScheme = oneOfStringsCI schemes
397+
395398-- | Parses a URI. Returns pair of original and URI-escaped version.
396399uri :: Parser [Char] st (String, String)
397400uri = try $ do
398− scheme <- oneOfStringsCI schemes
401+ scheme <- uriScheme
399402 char ':'
400403 -- /^[\/\w\u0080-\uffff]+|%[A-Fa-f0-9]+|&#?\w+;|(?:[,]+|[\S])[%&~\w\u0080-\uffff]/
401404 -- We allow punctuation except at the end, since
src/Text/Pandoc/Readers/Markdown.hs+1−1
@@ -1543,7 +1543,7 @@ referenceLink constructor (lab, raw) = do
15431543
15441544bareURL :: MarkdownParser (F Inlines)
15451545bareURL = try $ do
1546− guardEnabled Ext_autolink_urls
1546+ guardEnabled Ext_autolink_bare_uris
15471547 (orig, src) <- uri <|> emailAddress
15481548 return $ return $ B.link src "" (B.str orig)
15491549
tests/Tests/Readers/Markdown.hs+1−1
@@ -24,7 +24,7 @@ infix 4 =:
2424testBareLink :: (String, Inlines) -> Test
2525testBareLink (inp, ils) =
2626 test (readMarkdown def{ readerExtensions =
27− Set.fromList [Ext_autolink_urls] })
27+ Set.fromList [Ext_autolink_bare_uris] })
2828 inp (inp, doc $ para ils)
2929
3030autolink :: String -> Inlines