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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -1036,9 +1026,10 @@ export default class MarkdownPreview extends React.Component { | |||
|
|||
if (!href) return | |||
|
|||
const regexNoteInternalLink = /main.html#(.+)/ | |||
const extractId = /(main.html)*#/ |
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.
Shouldn't it be /(main.html)?#/
?
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.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
LGTM π
@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.js
in 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.js
I think that the file path which is written in
href
of<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