diff options
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Options.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 |
3 files changed, 14 insertions, 0 deletions
@@ -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 '<' |