Skip to content

Add ability to generate stable heading id for non english languages by setting myst_fully_normalize_name_slug_func#1019

Closed
Alexey-NM wants to merge 6 commits into
executablebooks:masterfrom
global-system:fully_normalize_name_slug_func
Closed

Add ability to generate stable heading id for non english languages by setting myst_fully_normalize_name_slug_func#1019
Alexey-NM wants to merge 6 commits into
executablebooks:masterfrom
global-system:fully_normalize_name_slug_func

Conversation

@Alexey-NM

@Alexey-NM Alexey-NM commented Jan 27, 2025

Copy link
Copy Markdown

They need stable heading id to make refrences to headers from external documentation (some_chapter.html#zagalovok).
Unfortunately If there are titles 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.

This merge request allows to generate stable ids by setting myst_fully_normalize_name_slug_func in config.py

myst_fully_normalize_name_slug_func = 'utils.fully_normalize_name_by_any_lang'
def fully_normalize_name_by_any_lang(str:str)->str:
    normalize_name = ' '.join(str.lower().split())
    tr_str = translit(normalize_name,"ru",reversed=True)
    result = _make_id(tr_str)
    return result

It generates an english name from other language. It allows to use static id.

See also: #968 (comment)

Copy link
Copy Markdown
Member

Closing in favour of #1158, which addresses the underlying problem (#968) differently: the GitHub-style slug — including for non-English headings, e.g. #заголовок — is now emitted as a real, stable HTML anchor, and myst_heading_slug_func gains named presets, so no second callable-based config option is needed (we are also moving configuration towards plain declarative values). Thanks for the contribution and for highlighting the non-English-ids gap — it directly shaped that work.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants