-
Notifications
You must be signed in to change notification settings - Fork 329
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
Support wiki links with special characters and fix links to headings #1040
Conversation
🦋 Changeset detectedLatest commit: 1663b09 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 9 Ignored Deployments
|
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.
@Gutts-n Thank you for submitting the PR. Good job! To make it even better I suggested a small change to the regex pattern.
Also, please remember to update the regex in this micromark html extension file.
Apart from that, could you please write unit tests for both the remarkWikiLink
plugin and its micromark html
extension? Please cover all the cases that seem to cause issues in Flowershow, like accented letters, hyphens, or parentheses.
And lastly, please add changeset file to this PR by running npx changeset
in the root of the repo and following the prompts to describe the changes that this PR aims to apply.
@Gutts-n Do you need any help? :) |
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.
Please take a look at my comments.
Also, we need to mirror these tests for the micromark extension, here: https://github.com/datopian/portaljs/blob/main/packages/remark-wiki-link/test/micromarkExtensionWikiLink.spec.ts
@olayway in tests here after the # in links is switching spaces with dashes, is this behavior expected? In obsidian we can link a file + header with spaces inside of another file. Is happening just in the first space of the linked file |
@Gutts-n No it definitely shouldn't replace only the first space 😅 Good catch! And the whole spaces->dash + lowercasing of headings was just a temporary solution that was supposed to produce hrefs matching id's generated by For now, please just replace this:
With this:
in both Then we can merge 🙂 |
… of wiki links and adjusted the unit tests
I finished here @olayway, just one thing that I noted is that the hChildren property of the tags is being generated this way, is it the expected scenario? |
@Gutts-n yes, this is correct. This is basically making sure that the text node inside of the anchor tag will have this value. And here it should be exactly the same as the text in the wikilink as there was no alias set. Here is the part of code where it is being set: And here is some docs explaining what are these https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes That being said... Well done!!! Great job! 🎉 Let's merge 😃 |
Fixes this broken test: datopian/flowershow#576
Changes
CC: @anuveyatsu @olayway @demenech