Overlapping regexes need to be disallowed
Problem
The regex for a link matches also on the start of a reference link.
If code is fenced inside back ticks it is also matched.
Solution
- Prioritise the order of the regexes
- Use
re.match
rather thanre.findall
to also give the location of the matches, and save these - Either only pass non matched code elements into the regex, or remove anything that is matched a second time