aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-09-27 13:43:48 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-09-27 13:43:48 -0700
commitbae39e77a82a911b5a861970a6680fbd0cfd5357 (patch)
tree52eca31284c7e62876a0acf7d382a898756f4d0b
parent15a8192b84639a1cb1c4d3750931c8c1bcf58aed (diff)
downloadpandoc-bae39e77a82a911b5a861970a6680fbd0cfd5357.tar.gz
Added Ext_autolink_urls.
-rw-r--r--README4
-rw-r--r--src/Text/Pandoc/Options.hs1
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
3 files changed, 14 insertions, 0 deletions
diff --git a/README b/README
index ba9be7b1d..d1358ee77 100644
--- a/README
+++ b/README
@@ -2254,6 +2254,10 @@ Note that the pandoc document model does not support
abbreviations, so if this extension is enabled, abbreviation keys are
simply skipped (as opposed to being parsed as paragraphs).
+**Extension: `autolink_urls`**\
+Makes all absolute URLs into links, even when not surrounded by
+pointy braces `<...>`.
+
Producing slide shows with Pandoc
=================================
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index a7d02ed10..f9930cf50 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -73,6 +73,7 @@ data Extension =
-- iff container has attribute 'markdown'
| Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
| Ext_monospace_autolinks -- ^ Put autolink text in monospace font
+ | Ext_autolink_urls -- ^ Make all absolute URLs 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
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 27e730f9f..6f4e5672e 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1159,6 +1159,7 @@ table = try $ do
inline :: Parser [Char] ParserState (F Inlines)
inline = choice [ whitespace
+ , bareURL
, str
, endline
, code
@@ -1471,6 +1472,14 @@ referenceLink constructor (lab, raw) = do
Nothing -> (\x -> B.str "[" <> x <> B.str "]" <> B.str raw') <$> fallback
Just (src,tit) -> constructor src tit <$> lab
+bareURL :: Parser [Char] ParserState (F Inlines)
+bareURL = try $ do
+ guardEnabled Ext_autolink_urls
+ (orig, src) <- uri <|> emailAddress
+ (guardEnabled Ext_monospace_autolinks >>
+ return (return $ B.link src "" (B.codeWith ("",["url"],[]) orig)))
+ <|> return (return $ B.link src "" (B.str orig))
+
autoLink :: Parser [Char] ParserState (F Inlines)
autoLink = try $ do
char '<'