-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Add support for markdown links. #835
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening the PR @skilldeliver.
Would you be up for adding some unit tests to test/client/lib/textUtils.ts
?
// Match http or https then domain name (with optional port) then any text that ends with letter or number. | ||
export const urlRegex = /(https?:\/\/[A-Za-z\d][A-Za-z\d-.]*(?!\.)(?::\d+)?(?:\/[^\s]*)?[\w\d/])/; | ||
// Match http or https then domain name and capture markdown link text and URL separately | ||
const urlRegex = /(?:\[(.*?)\]\()?https?:\/\/[A-Za-z\d][A-Za-z\d-.]*\.[A-Za-z]{2,}(?::\d+)?(?:\/[^\s)]*)?(?:\))?/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would match strings like [Google](https://www.google.com
or https://www.google.com)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right @georgegevoian - the regex needs fix;
I will take a look how can I add tests.
Btw one of the CI tests of nbrowser is failing and I can't understand why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DetailView does not opens cell for editing when clicked on link
looks to be failing because a localhost URL isn't being treated as a link (most likely a regression in the regex).
The other failures look unrelated - we'll be landing a fix on main
soon.
Thanks.
Is this feature maybe mostly redundant to the new markdown cell format feature? https://support.getgrist.com/col-types/#markdown |
Yeah, I also think so! |
This PR introduces markdown link detection and rendering. To achieve this, the regex has been updated, and an additional property, link, has been added to the tokens. If it's a URL, the URL remains the same, with the actual text rendered. However, for markdown, we aim to have a named link where the text differs from the link.
Screenshot examples:
Here is the raw text content
Here is the rendered
Special thanks to Darius for recognizing the need for named links.