Repository navigation
Description
1. Summary
I couldn’t find how I can preserve non-ASCII symbols and letter case in my anchors (fragment identifiers) without Markdown markup written especially for MyST and without extra Python functions. If it’s currently impossible, it would be nice to add this feature.
2. MCVE
2.1. File
kira-russian-headings.md:
```{contents} Table of Contents
```
# Кира
Богиня2.2. Steps to reproduce
pipenv install --dev myst-parser
pipenv run myst-docutils-demo kira-russian-headings.md2.3. Behavior
2.3.1. Current
<nav class="contents" id="table-of-contents" role="doc-toc">
<p class="topic-title"><a class="reference internal" href="#top">Table of Contents</a></p>
<ul class="simple">
<li><p><a class="reference internal" href="#section-1" id="toc-entry-1">Кира</a></p></li>
</ul>
</nav>
<section id="section-1">
<h1><a class="toc-backref" href="#toc-entry-1" role="doc-backlink">Кира</a></h1>
<p>Богиня</p>
</section>2.3.2. Desired
- href="#section-1"
+ href="#Кира"- <section id="section-1">
+ <section id="Кира">2.3.3. ids with autogenerated values
Also, in my example, MyST generated by default the id with the meaningless value toc-entry-1. But it seems that this problem is out of the scope of this issue.
3. Argumentation for the need for the feature
3.1. Why non-ASCII characters in anchors?
-
Non-English users are people too. They should have a possibility to write anchors in their languages.
-
See the post “Google: Using non-English URLs for non-English websites is fine”:
Google Senior Webmaster Trends Analyst John Mueller said in a recent SEO snippets video that using non-English URLs for non-English websites is fine and that Google is able to crawl, index and rank them.
This includes non-Latin characters in your URLs. John Mueller said “as long as URLs are valid and unique, that’s fine.” He added, “So to sum it up, yes, non-English words and URLs are fine, [and] we recommend using them for non-English websites.”
3.2. Why mixed case in anchors?
-
URLs may be more user-friendly. See the example written by the user @Dirigible on Stack Overflow:
The point of a URL is to have a user-friendly representation of a page, and if your url is friendlier with upper case, why not use it?
moviesforyoutowatch.com/batman-vii-the-dark-knight-whatevers
MoviesForYouToWatch.com/Batman-VII-The-Dark-Knight-Whatevers
-
Writing a tool that converts mixed kebab case to lowercase (for example, if a hosting, like Netlify, forces to have lowercase URLs) shouldn’t be a big problem. Converting lowercase to mixed case is a more complex task, because a tool for conversion should know the original case.
4. Current status of customizing anchors
Please correct me if I’ve understood something wrong.
4.1. Related resources
I found these pages:
- The section “Anchor slug structure” in the MyST documentation.
- The pull request “NEW: stable heading anchors: shared slug module, presets, HTML ids, explicit-id priority”. Such AI-generated texts may be hard to understand for humans.
4.2. Forced anchors converting
- Users of the Docutils mode are forced to agree with converting non-ASCII anchors to anchors like
section-1. - Users of the Sphinx mode may also select one of the presets
gitlaborgithub. Users of these presets are forced to use lowercase letter case.
5. Example of desired behavior in another software
The plugin Markdown TOC for Sublime Text allows users to get control over their TOC, headers, and anchors.
For generating non-ASCII mixed case anchors, Markdown TOC users should just add the option uri_encoding="false" to the plugin configuration:
- [**Примеры русского**](#Примеры-русского)
# Примеры русскогоIt would be nice to have similar behavior for MyST.
Thanks.
Activity