Adjust regex so that it does not strip links inadvertently #232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue with the current implementation seems to stem from the regex pattern mistakenly capturing and modifying links that should be left untouched, especially when they contain colons (:) or semicolons (;) that are part of a normal URL or anchor reference (#).
This was leading to issues where text would be lost where a paragraph would contain more than one link and a semi-colon.
eg:
Citation 4. [footnote 4](#ftnt4) Citation 5. [footnote 5](#ftnt5) Citation 6; [footnote 6](#ftnt6)
<p>Citation 4. <a href="#ftnt4">footnote 4</a> Citation 5. <a href=";">footnote 5</a></p>
<p>Citation 4. <a href="#ftnt4">footnote 4</a> Citation 5. <a href="#ftnt5">footnote 5</a> Citation 6; <a href="#ftnt6">footnote 6</a></p>
This PR fixes this so that regular links are preserved, but keeps in place the logic stripping bad protocols.
Closes this issue: