Cmark: Autolinking syntax `<...>` vs. `[[...]]`

Hi,

while I am very much in favor of all the syntax decisions of the original markdown syntax and the cmark spec, personally I dislike the autolink syntax <http://www.example.com> (gruber, cmark spec), because:

  • It’s only for absolute urls like http:// and mailto:// and not for relative urls - where such a syntax would be quite useful (think wiki cross-references)
  • It’s hard to tell apart from html tags - you have to check if it’s an url to tell.

I am very much in favor of the quite common Mediawiki linking syntax [[Hello]] (Mediawiki Links) which nicely goes together with the markdown link syntax [text](url), is great for relative links and much less in conflict with other syntax.

Over the years I enabled this kind of links via different workarounds, like having a regex convert the links before parsing the document. I am a bit fed up of these workarounds but don’t want to give up linking via [[...]] in my markdown documents. I am working on a personal fork of ruby commonmarker/cmark-gfm to properly support this syntax for my own purposes.

I know markdown is what it is and the spec should honor this and with the markdown-universe being so fragmented already, I am almost afraid of asking. But anyway, I wondered:

  • Conceptionally, is there a reason [[...]] should not be parsed as links in markdown? (even optionally/through an extension)
  • Would something like this have a chance to be an option/extension in cmark?
  • Is somebody else interested in parsing such links with cmark / is there maybe existing code in this direction already? (I researched a bit around but couldn’t find anything so far)

Greetings,

Ralf

I may share your dislike for the the <...> autolink syntax, but consider the backward compatibility problem.

EDIT: Also consider that many implementations (this site, cmark-gfm, md4c and likely many more) also implement more permissive autolinks as an extension and can recognize absolute URLs even without the <...> decorations (e.g. https://www.example.com or even just www.example.com).

I also believe that Markdown is quite a natural format for wiki implementations. If so, then we need to reserve the [[...]] syntax for wiki links, i.e. links pointing to other articles within the wiki database (no matter whether as a future feature of CommonMark or as an extension to it) and not to use it as a general-purpose links.

Is somebody else interested in parsing such links with cmark / is there maybe existing code in this direction already? (I researched a bit around but couldn’t find anything so far)

MD4C implements wiki-links as an extension since version 0.4.0.

2 Likes

The use of < and > to delimit URLs dates back to RFC 1738 in 1994, and arguably even earlier because it was used to delimit e-mail addresses in RFC 822. I think it’s probably too late to abandon it.

However, there’s certainly a case for reserving [[ ]] for wiki links.

2 Likes