Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Anchor HTML Tags Text Is Escaped by No Bare URLs #588

Closed
dbobak opened this issue Jan 14, 2023 · 9 comments · Fixed by #606
Closed

Bug: Anchor HTML Tags Text Is Escaped by No Bare URLs #588

dbobak opened this issue Jan 14, 2023 · 9 comments · Fixed by #606
Assignees
Labels
bug Something isn't working markdown General Markdown or Markdown related issue or feature resolution/update-made A change has been made that should resolve this issue or request

Comments

@dbobak
Copy link

dbobak commented Jan 14, 2023

In Custeom Regex Replacement section I'm trying to convert HTML links to markdown links with that regex:

find: <a.*?href=["']([^"']*)["'][^>]*>([^<]*)<\/a> igm [$2]($1)

Generally it works, but sometimes it fails, for example in this case:

Wycinek utworzono z: <a href="https://www.tygodnikpowszechny.pl/zycie-pod-mikroskopem-151274" class="tc-tiddlylink-external" rel="noopener noreferrer" target="_blank">https://www.tygodnikpowszechny.pl/zycie-pod-mikroskopem-151274</a>

the link is converted to:

Wycinek utworzono z: <a href="https://www.tygodnikpowszechny.pl/zycie-pod-mikroskopem-151274" class="tc-tiddlylink-external" rel="noopener noreferrer" target="_blank"><https://www.tygodnikpowszechny.pl/zycie-pod-mikroskopem-151274</a>>

When testing in https://regexr.com/, my regex works fine.

@dbobak dbobak added the bug Something isn't working label Jan 14, 2023
@pjkaufman
Copy link
Collaborator

This seems interesting. I am not sure what is going on here, but I need to check the regex and make sure it doesn't need any escaping in it.

@pjkaufman
Copy link
Collaborator

The following is what I got when I added the custom regex you provided as a custom regex replacement:

Wycinek utworzono z: [https://www.tygodnikpowszechny.pl/zycie-pod-mikroskopem-151274](https://www.tygodnikpowszechny.pl/zycie-pod-mikroskopem-151274)

This looks correct to me. @dbobak, could you provide your whole data.json file so I can attempt to reproduce the issue with all of the rules you normally have on? It is likely one of them is causing something to be converted in a weird way so the regex no longer matches.

@dbobak
Copy link
Author

dbobak commented Jan 26, 2023

Yes, of course:

data.json.zip

@pjkaufman
Copy link
Collaborator

I am able to reproduce. If I had to guess, you have No Bare URLs turned on which is not really good at figuring out when a link is in an anchor tag already. I will take a closer look and see if that rules is on and if turning it off will fix the issue. If so, I may need to think up a way around this issue.

@pjkaufman
Copy link
Collaborator

Yeah. It is a problem with No Bare URLs. Let me see if I can ignore anchor tags for No Bare URLs.

@pjkaufman
Copy link
Collaborator

I may have a fix for this. I just need to test it out and if it works. I will merge it in for next release.

@pjkaufman
Copy link
Collaborator

Looks like my fix works with your config. I will push it up and see how it goes.

@pjkaufman pjkaufman added the markdown General Markdown or Markdown related issue or feature label Jan 27, 2023
@pjkaufman pjkaufman self-assigned this Jan 27, 2023
@pjkaufman
Copy link
Collaborator

The fix for this should be on master and in the next release. Please let us know if that is not the case.

@pjkaufman pjkaufman changed the title Bug: regex problem Bug: Anchor HTML Tags Text Is Escaped by No Bare URLs Jan 27, 2023
@pjkaufman pjkaufman added the resolution/update-made A change has been made that should resolve this issue or request label Jan 27, 2023
@dbobak
Copy link
Author

dbobak commented Jan 29, 2023

@pjkaufman, I confirm that this is No Bare URLs problem. After turning off that option, the regex works as expected. If the new release will be published, I'll let know if the fix is working for me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working markdown General Markdown or Markdown related issue or feature resolution/update-made A change has been made that should resolve this issue or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants