Fixes that TOC hasn't id attribute when the title is all 2-byte characters#2994
Conversation
|
The TOC is broken, can you fix it? It tries to open the TOC link as an attachment I guess. |
When the anchor element in Therefore, I added |
| if (hashLink !== '' && isHeadingInMarkdownPreview && targetEl) { | ||
| const dataLine = targetEl.dataset.line | ||
| a.onclick = () => { | ||
| this.scrollTo(dataLine) |
There was a problem hiding this comment.
Can you move this code into this function? Because we already have an existing link click listener.
https://github.com/BoostIO/Boostnote/blob/9a6ee9d2ef2d853b623d386c928088356ba4dbce/browser/components/MarkdownPreview.js#L1014-L1024
There was a problem hiding this comment.
I understood. I fixed it.
Since the link hash this time did not match the regular expression, the regular expression has been changed.
https://github.com/BoostIO/Boostnote/blob/857367efba4312b842b5ece6fd5e6912702090ff/browser/components/MarkdownPreview.js#L1029-L1030
e.g.

| if (!href) return | ||
|
|
||
| const regexNoteInternalLink = /main.html#(.+)/ | ||
| const extractId = /(main.html)*#/ |
There was a problem hiding this comment.
Shouldn't it be /(main.html)?#/ ?
There was a problem hiding this comment.
There was a problem hiding this comment.
I understand that, it's just I want to replace the regex from (main.html)*# to (main.html)?#. But I think it doesn't matter 😄 We can go by your way then.
There was a problem hiding this comment.
I'm sorry. I misunderstood that this line was not necessary.
Thank you for a suggestion. I think (main.html)?# is better than (main.html)*# too.
|
@roottool Can you resolve the conflict? |
|
I solved the conflict by adopting the master branch code. Because I don't want to change the code of the current master branch. Screenshot |
|
This might be related to some recent issues with 0.13.0 |




Description
This PR fixes that TOC hasn't id attribute when the title is all 2-byte characters.
I referred to
browser/lib/slugify.jsin 4f9b374 and a logic of Slug in Visual Studio Code.According to RFC3986, the underscore can be used in URI.
So, I don't replace the underscore.
"."and"~"is used by file path.e.g.
~/example.jsI think that the file path which is written in
hrefof<a>is a security risk.Therefore, I exclude
"."and"~".Screenshot
Issue fixed
#2920
Type of changes
Checklist:
IssueHunt Summary
Referenced issues
This pull request has been submitted to:
IssueHunt has been backed by the following sponsors. Become a sponsor