← Back to team overview

maria-docs team mailing list archive

TOC link doesn't work if a heading doesn't include ASCII alphanumerics

 

Hello,

A link in a table of contents generated by <<toc>> macro doesn't work if its corresponding heading doesn't include ASCII alphanumerics.
The reason is that characters that can not be converted into ASCII alphanumerics are treated as spaces in headings.
If a heading only includes the characters, its "id" attribute is an empty string.
For example, this page: https://mariadb.com/kb/zh-cn/getting-started-with-indexes/

As of now, a editor need to append an extra <<style>> macro to avoid the dead link.
For example: "== 第一章 <<style style="content: 'Heading One';">> <</style>>" (https://mariadb.com/kb/ja/toc/)

I think a possible solution would be to treat some non-ASCII characters as ASCII alphanumerics.
For example, "== 第一章" would be converted to "<h2 id="第一章">第一章</h2>".
The character probably can be expressed by this regular expression: /[\p{Cyrillic}\p{Han}\p{Hangul}\p{Hiragana}\p{Katakana}]/

Thanks,
--
100の人


Follow ups