Why you assume there’s only one link in the line?
They did not want external (http) links to be modified as that would break it:
- ✅
[Example](https://example.com/#Some%20Link)
- ❌
[Example](https://example.com/#some-link)
I compromised by thinking that it might be unlikely enough to have an external http link AND internal link within the same line. You could probably still do it, my first thought was [^h][^t][^t][^p]
but that would cause issues for #ttp
and #A
so i just gave up. Instead I think you’d want a different approach, like breaking each link onto their own line, do the same external/internal check before the substitution, and join the lines afterward.
Also, you perform substitutions in the whole URL instead of the fragment component
That requirement i missed. I just assumed the filename would be replaced the same way too Lol. Not too hard to fix tho :)
I did it!! It also handles the case where an external link and internal link are on the same line :D
Here is my annotated file