mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6561: glossary: Wrong hyperlinks are generated for non alphanumeric terms
This commit is contained in:
parent
ef2f1057cd
commit
b56390644d
1
CHANGES
1
CHANGES
@ -54,6 +54,7 @@ Bugs fixed
|
|||||||
* #5592: std domain: :rst:dir:`option` directive registers an index entry for
|
* #5592: std domain: :rst:dir:`option` directive registers an index entry for
|
||||||
each comma separated option
|
each comma separated option
|
||||||
* #6549: sphinx-build: Escaped characters in error messages
|
* #6549: sphinx-build: Escaped characters in error messages
|
||||||
|
* #6561: glossary: Wrong hyperlinks are generated for non alphanumeric terms
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -255,9 +255,9 @@ def make_glossary_term(env: "BuildEnvironment", textnodes: Iterable[Node], index
|
|||||||
new_id = nodes.make_id('term-' + termtext)
|
new_id = nodes.make_id('term-' + termtext)
|
||||||
if new_id == 'term':
|
if new_id == 'term':
|
||||||
# the term is not good for node_id. Generate it by sequence number instead.
|
# the term is not good for node_id. Generate it by sequence number instead.
|
||||||
new_id = 'term-' + str(len(gloss_entries))
|
new_id = 'term-%d' % env.new_serialno('glossary')
|
||||||
if new_id in gloss_entries:
|
while new_id in gloss_entries:
|
||||||
new_id = 'term-' + str(len(gloss_entries))
|
new_id = 'term-%d' % env.new_serialno('glossary')
|
||||||
gloss_entries.add(new_id)
|
gloss_entries.add(new_id)
|
||||||
|
|
||||||
std = cast(StandardDomain, env.get_domain('std'))
|
std = cast(StandardDomain, env.get_domain('std'))
|
||||||
|
@ -244,6 +244,17 @@ def test_glossary_sorted(app):
|
|||||||
[nodes.definition, nodes.paragraph, "description"])
|
[nodes.definition, nodes.paragraph, "description"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_glossary_alphanumeric(app):
|
||||||
|
text = (".. glossary::\n"
|
||||||
|
"\n"
|
||||||
|
" 1\n"
|
||||||
|
" /\n")
|
||||||
|
restructuredtext.parse(app, text)
|
||||||
|
objects = list(app.env.get_domain("std").get_objects())
|
||||||
|
assert ("1", "1", "term", "index", "term-1", -1) in objects
|
||||||
|
assert ("/", "/", "term", "index", "term-0", -1) in objects
|
||||||
|
|
||||||
|
|
||||||
def test_cmdoption(app):
|
def test_cmdoption(app):
|
||||||
text = (".. program:: ls\n"
|
text = (".. program:: ls\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -131,4 +131,4 @@ def test_create_index_by_key(app):
|
|||||||
assert len(index) == 3
|
assert len(index) == 3
|
||||||
assert index[0] == ('D', [('docutils', [[('main', '#term-docutils')], [], None])])
|
assert index[0] == ('D', [('docutils', [[('main', '#term-docutils')], [], None])])
|
||||||
assert index[1] == ('P', [('Python', [[('main', '#term-python')], [], None])])
|
assert index[1] == ('P', [('Python', [[('main', '#term-python')], [], None])])
|
||||||
assert index[2] == ('ス', [('スフィンクス', [[('main', '#term-2')], [], 'ス'])])
|
assert index[2] == ('ス', [('スフィンクス', [[('main', '#term-0')], [], 'ス'])])
|
||||||
|
Loading…
Reference in New Issue
Block a user