Added Ext_autolink_urls.

This commit is contained in:
John MacFarlane 2012-09-27 13:43:48 -07:00
parent 15a8192b84
commit bae39e77a8
3 changed files with 14 additions and 0 deletions

4
README
View file

@ -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
=================================

View file

@ -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

View file

@ -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 '<'