New Code!
Discount has been pushed up to version 1.4.1 with the addition of a couple of small new features that were suggested by Mike Schiraldi @reddit.com:
- “autolinks” – expand unbracketed urls into links (flag MKD_AUTOLINK, -fautolink in the markdown program)
- “safe links” – don’t linkify footnotes where the link protocol isn’t a well-known protocol (currently http: https:,ftp:,news:) (flag MKD_SAFELINK, -fsafelink in the markdown program)
The first feature (MKD_AUTOLINK
) lets you set discount into a mode where every url it finds will
be converted into a hyperlink – if your source discount mentions a url, it will be
hyperlinked without having to <>
it or wrap it in a []
link.
The second link (MKD_SAFELINK
) makes discount do sanity checks on the url provided in a []
link; if the url isn’t a local reference (starting with a /
,) or a http://
, https://
, ftp://
or news://
-type url, the []
will not be expanded into a hyperlink but will simply be left as ugly text. This, apparently, helps prevent excitement when someone attempts to embed a script into a []
link (I’ve not encountered that myself, because none of the places I use discount allow users to enter their own []
links.
I’ve also put a couple of small optimizations into the code, but they do not affect output at all as far as I have been able to detect. They might speed things up a little
bit (I had a url checking loop that was doing repeated strlen()
calls on constants in an array, and I replaced that array with a structure containing the constant and the length of the constant; strlen()
might be a fairly cheap function call, but it’s still a lot more expensive than a structure dereference.
I’ve been testing this and playing around with it for a couple of days, so it (heh heh) works for me. Why not try it out? After all, it’s New Code!