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
{{ message }}
Repository navigation
Support stable heading id for non english languages #968
I need ability to make refrences to headers from external documentation (some_chapter.html#zagalovok).
Unfortunately If I have a title in a non english language it will have numeric id which can be changed in any time.
It is difficult to automate and it is unstable because such number can be changed at any time.
<sectionid="id2">
Solution
I want to have the ablility to define the id generation function in my conf.py to a function that accepts a string and returns a stable id.
The function will generate stable id by a node title.
defmake_id_by_any_lang(str:str)->str:
# see https://pypi.org/project/transliterate/tr_str=translit(str,"ru",reversed=True)
#This function is a modified version of ``docutils.nodes.make_id()`` of#docutils-0.16# It is test code so probably it is not nessasaryresult=_make_id(tr_str).lower()
returnresult
Activity
Alexey-NM commentedon Aug 26, 2024
Alternative decision is to add ability configuring custom markdown plugins.
A plugin can add id to token similar to attrs_block extension
It is not difficult to add custom function to configure
mdin create_md_parserchrisjsewell commentedon Aug 27, 2024
Heya, what exactly does
make_id_by_any_langdo, how is it different toMyST-Parser/myst_parser/mdit_to_docutils/base.py
Lines 774 to 775 in 1038800
Alexey-NM commentedon Aug 27, 2024
It generates an english name from other language. It allows to use static id.
Alexey-NM commentedon Jan 27, 2025
We have implemented pull request which allows to do it