You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is recognized as not a problem of vscode itself, but because it is used in Markdown extension.
PR: markdown-it-named-header custom slugify for non-latin characters #20628
PROBLEM:
I want to realize an in-page link by using an anchor in Markdown Preview, but it does not work with non-latin characters.
If the header is written in non-latin characters (such as Japanese), it is judged to be an invalid character, so the value of the id attribute is empty.
BACKGROUND:
Markdown-it-named-headers (mdnh) generates an id attribute from Markdown's header element and uses the slug() function provided by strings.js to convert the text to valid URL slug.
example:
# Example Header --><h1id="example-header">Example</h1>
There is a problem with non-latin characters.
If the header is written in non-latin characters (such as Japanese), it is judged to be an invalid character, so the value of the id attribute is empty.
As a result of investigation, processing of non-latin characters can not be performed correctly.
(However, it may be correct in the sense that it deletes a character string that can not be used in the URL.)
In Markdown extension, there is a process of creating an href link from a header when anchor (#anchor) is specified and rendering <a href=""> tag.
In this process, the non-latin characters appear to be encodeURI.
I think it is a very good process.
Markdown-it-named-headers has an option to define custom slugify.
So, when a non-latin character was written in the header, I decided to define its custom slug() function.
This issue is recognized as not a problem of vscode itself, but because it is used in Markdown extension.
PR: markdown-it-named-header custom slugify for non-latin characters #20628
PROBLEM:
I want to realize an in-page link by using an anchor in Markdown Preview, but it does not work with non-latin characters.
If the header is written in non-latin characters (such as Japanese), it is judged to be an invalid character, so the value of the id attribute is empty.
BACKGROUND:
Markdown-it-named-headers (mdnh) generates an id attribute from Markdown's header element and uses the slug() function provided by
strings.js
to convert the text to valid URL slug.example:
There is a problem with non-latin characters.
If the header is written in non-latin characters (such as Japanese), it is judged to be an invalid character, so the value of the id attribute is empty.
As a result of investigation, processing of non-latin characters can not be performed correctly.
(However, it may be correct in the sense that it deletes a character string that can not be used in the URL.)
Sample Markdown:
Rendered HTML:
In Markdown extension, there is a process of creating an href link from a header when anchor
(#anchor)
is specified and rendering<a href="">
tag.In this process, the non-latin characters appear to be encodeURI.
I think it is a very good process.
Markdown-it-named-headers has an option to define custom slugify.
So, when a non-latin character was written in the header, I decided to define its custom slug() function.
HTML rendered with custom slugify applied:
Screenshot:
This is the best for me. Please tell me if there is any other better way.
The text was updated successfully, but these errors were encountered: