git.iko.soy/typeable/pandoc
on master help sign in
Added Ext_autolink_urls.
bae39e7John MacFarlane
@@ -2254,6 +2254,10 @@ Note that the pandoc document model does not support
2254abbreviations, so if this extension is enabled, abbreviation keys are
2254abbreviations, so if this extension is enabled, abbreviation keys are
2255simply skipped (as opposed to being parsed as paragraphs).
2255simply skipped (as opposed to being parsed as paragraphs).
2256
2256
2257+**Extension: `autolink_urls`**\
2258+Makes all absolute URLs into links, even when not surrounded by
2259+pointy braces `<...>`.
2260+
2257Producing slide shows with Pandoc
2261Producing slide shows with Pandoc
2258=================================
2262=================================
2259
2263
src/Text/Pandoc/Options.hs+1
@@ -73,6 +73,7 @@ data Extension =
73 -- iff container has attribute 'markdown'
73 -- iff container has attribute 'markdown'
74 | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
74 | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
75 | Ext_monospace_autolinks -- ^ Put autolink text in monospace font
75 | Ext_monospace_autolinks -- ^ Put autolink text in monospace font
76+ | Ext_autolink_urls -- ^ Make all absolute URLs into links
76 | Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters
77 | Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters
77 | Ext_startnum -- ^ Make start number of ordered list significant
78 | Ext_startnum -- ^ Make start number of ordered list significant
78 | Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php
79 | Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php
src/Text/Pandoc/Readers/Markdown.hs+9
@@ -1159,6 +1159,7 @@ table = try $ do
1159
1159
1160inline :: Parser [Char] ParserState (F Inlines)
1160inline :: Parser [Char] ParserState (F Inlines)
1161inline = choice [ whitespace
1161inline = choice [ whitespace
1162+ , bareURL
1162 , str
1163 , str
1163 , endline
1164 , endline
1164 , code
1165 , code
@@ -1471,6 +1472,14 @@ referenceLink constructor (lab, raw) = do
1471 Nothing -> (\x -> B.str "[" <> x <> B.str "]" <> B.str raw') <$> fallback
1472 Nothing -> (\x -> B.str "[" <> x <> B.str "]" <> B.str raw') <$> fallback
1472 Just (src,tit) -> constructor src tit <$> lab
1473 Just (src,tit) -> constructor src tit <$> lab
1473
1474
1475+bareURL :: Parser [Char] ParserState (F Inlines)
1476+bareURL = try $ do
1477+ guardEnabled Ext_autolink_urls
1478+ (orig, src) <- uri <|> emailAddress
1479+ (guardEnabled Ext_monospace_autolinks >>
1480+ return (return $ B.link src "" (B.codeWith ("",["url"],[]) orig)))
1481+ <|> return (return $ B.link src "" (B.str orig))
1482+
1474autoLink :: Parser [Char] ParserState (F Inlines)
1483autoLink :: Parser [Char] ParserState (F Inlines)
1475autoLink = try $ do
1484autoLink = try $ do
1476 char '<'
1485 char '<'