-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Punctuation at end of URL in comments incorporated into link, breaking the link #10944
Comments
Thank you! I think we should be able to address this by tweaking the markdown interpreter. The comment body is rendered here: plots2/app/views/notes/_comment.html.erb Lines 146 to 149 in 7c3af44
But it's parsed from markdown here: Lines 505 to 524 in ecae3b9
Yes, so the RDiscount markdown parser we use does the same thing: RDiscount.new("the BLM Surface Management Handbook: https://www.blm.gov/sites/blm.gov/files/H-3809-1.pdf.",:autolink).to_html
=> "<p>the BLM Surface Management Handbook: <a href=\"https://www.blm.gov/sites/blm.gov/files/H-3809-1.pdf.\">https://www.blm.gov/sites/blm.gov/files/H-3809-1.pdf.</a></p>\n" Other systems are affected but GFM says Commonmark doesn't address the issue. Other platforms have had to make this fix too and even in earlier versions of Ruby. Also noting this is only affecting comments, not wikis; see the link to the Gitter chatroom at https://publiclab.org/wiki/gsoc-ideas#Get+in+touch where the URL is correctly parsed. I think this is because we don't use RDiscount's plots2/app/views/notes/show.html.erb Line 76 in 7c3af44
Let's try the same for comments. That means we remove the plots2/app/views/notes/_comment.html.erb Line 148 in 7c3af44
So it would look like this:
This could be a good FTO, but we have to watch out for whether it breaks any tests, as it's a pretty obscure change! ALSO: Noting that this could come up again potentially if the React comment renderer is different? @noi5e do you think this might be an issue? This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @publiclab/reviewers to get it labelled. Or, if this is not your first time, try to solve it yourself! |
So I decided to implement the fix on my local branch just to visually check out the effects on GitPod. Links no longer break but it looks like the React comment renderer is being affected. Links don't appear as hyperlinks once the react flag is set to true. Everything is rendered as normal text. I've attached a short demo. react-comment-renderer-demo.1.mp4
Wasn't able to verify if the change was breaking any test on my local. I'm using sqlite3 for my db and so, not all my tests pass on a normal day 😞. |
Excellent digging, @PeculiarE! And thorough testing, thank you! Hmm, ok, so I think what's happening is that we removed autolink from early in the process, and added it AFTER the react and non-react processes diverge. So possibly it is now working in non-react, but we have to find the corresponding spot where the react version needs an autolink step added. We may need some help from @noi5e to track where that is. I can see comment body templates in React are here: https://github.com/publiclab/plots2/blob/main/app/javascript/components/CommentDisplay.js Could the spot to re-introduce autolink be here? plots2/app/helpers/comment_helper.rb Line 28 in 5ec93e0
|
Thank you @jywarren ❤️ So you were right on on the correct spot to reintroduce autolink to the react version. Tested it on GitPod and the hyperlinks rendered properly on the React system. 🚀 🎉...please see the demo below react-comment-renderer-demo.2.mp4I believe this fixes the issue completely on both commenting systems. May I go ahead and add it to the open FTO issue at #10947? |
Excellent work @PeculiarE! Yes, feel free to add this to the open FTO you mentioned, or even create a new one. |
Thank you ❤️ @noi5e! I've created a new FTO issue for this.. |
Hi @jywarren, since the two FTOs (and the resulting PRs) created to resolve this issue have been successfully merged and closed, can we consider this issue closed? |
Yes sounds good!! Thank you! |
Posting for BHamster:
Please describe the problem
When making a comment on a post, if people paste a whole URL at the end of a sentence and put a period at the end of the URL, the hyperlink that automatically generates in the published comment incorporates the period and then becomes a bad link. e.g., this recent comment.
Please show us where to look
https://publiclab.org/questions/bhamster/02-10-2022/is-there-federal-level-recourse-that-communities-can-take-when-mine-reclamation-is-not-being-done-properly#c29860
Thank you!
The text was updated successfully, but these errors were encountered: