Closed Gutts-n closed 7 months ago
Latest commit: 1663b09a860726ed39bebba34fe634e48a46afcb
The changes in this PR will be included in the next version bump.
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 ↗︎
@Gutts-n Do you need any help? :)
@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 With a dash on the first position, it'll change the second space
@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 rehype-slug
, which is another package we use in Flowershow to add ids to headings (so that they can be linked to). However, rehype-slug
's generation of id from the content of the heading is not this simplistic. They use github-slugger under the hood. Please look at examples of input and output headings of rehype-slug
here: https://github.com/rehypejs/rehype-slug#use. As you can see, there's more than just replacing spaces with dashes and lowercasing. It would be great if you'd like to work on that too sometime 🙂 How I would do it is I'd make the remark-wiki-link
plugin generate headings using github-slugger
as well by default, and I'd allow users to pass their own custom transformer.
For now, please just replace this:
const headingId = heading.replace(/\s+/, "-").toLowerCase();
With this:
const headingId = heading.replace(/\s+/g, "-").toLowerCase();
in both html.ts
and fromMarkdown.ts
, and adjust/add relevant test cases.
Then we can merge 🙂
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 hProperties
or hChildren
used for:
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: https://github.com/datopian/flowershow/pull/576
Changes
CC: @anuveyatsu @olayway @demenech