Skip to content

URL autolinks are running inside `[]()` and `[]` blocks

The most correct way to fix this issue would be use use a negative lookbehind notation: https://www.regular-expressions.info/backref.html starting the regular expression with something like this:

(?<!\[)(?<!\]\()

But ruby StringScanner doesn't handle lookbehind correctly, according to my own experimentation and to this bug report https://bugs.ruby-lang.org/issues/7092

There is a possible new StringScanner which should be able to handle lookbehind situations: https://github.com/luikore/zscan but this is not the time to try to change that, as it will probably require a lot of work and benchmarking.

The solution here is to emulate the lookbehind and define the bondaries to not match [or ]( which would colide with the [*.?](*.?) tybe of block.

I've added test examples that cover this cases.

I've also tried to play with the order in which our autolink is processed, but looks like kramdown own link code does something funky that calls the other span filters, which in the end makes it useless to change the order for this specific case.

Closes #7 (closed)

Edited by Gabriel Mazetto

Merge request reports