mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6230: Inappropriate node_id has been generated by glossary directive
This commit is contained in:
parent
3f8a336d3a
commit
cda4642bc1
5
CHANGES
5
CHANGES
@ -9,6 +9,8 @@ Incompatible changes
|
||||
|
||||
* Ignore filenames without file extension given to ``Builder.build_specific()``
|
||||
API directly
|
||||
* #6230: The anchor of term in glossary directive is changed if it is consisted
|
||||
by non-ASCII characters
|
||||
|
||||
Deprecated
|
||||
----------
|
||||
@ -56,6 +58,9 @@ Features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #6230: Inappropriate node_id has been generated by glossary directive if term
|
||||
is consisted by non-ASCII characters
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
|
@ -257,6 +257,9 @@ def make_glossary_term(env, textnodes, index_key, source, lineno, new_id=None):
|
||||
termtext = term.astext()
|
||||
if new_id is None:
|
||||
new_id = nodes.make_id('term-' + termtext)
|
||||
if new_id == 'term':
|
||||
# the term is not good for node_id. Generate it by sequence number instead.
|
||||
new_id = 'term-' + str(len(gloss_entries))
|
||||
if new_id in gloss_entries:
|
||||
new_id = 'term-' + str(len(gloss_entries))
|
||||
gloss_entries.add(new_id)
|
||||
|
@ -120,4 +120,4 @@ def test_create_index_by_key(app):
|
||||
assert len(index) == 3
|
||||
assert index[0] == ('D', [('docutils', [[('main', '#term-docutils')], [], None])])
|
||||
assert index[1] == ('P', [('Python', [[('main', '#term-python')], [], None])])
|
||||
assert index[2] == ('ス', [('スフィンクス', [[('main', '#term')], [], 'ス'])])
|
||||
assert index[2] == ('ス', [('スフィンクス', [[('main', '#term-2')], [], 'ス'])])
|
||||
|
Loading…
Reference in New Issue
Block a user