mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Make genindex support RTL languages
If a string starts with an RTL mark, simply skip it and use the following character as the first letter.
This commit is contained in:
parent
046abd0577
commit
d534692a0e
@ -119,6 +119,8 @@ class IndexEntries(EnvironmentManager):
|
|||||||
# using specified category key to sort
|
# using specified category key to sort
|
||||||
key = category_key
|
key = category_key
|
||||||
lckey = unicodedata.normalize('NFD', key.lower())
|
lckey = unicodedata.normalize('NFD', key.lower())
|
||||||
|
if lckey.startswith(u'\N{RIGHT-TO-LEFT MARK}'):
|
||||||
|
lckey = lckey[1:]
|
||||||
if lckey[0:1].isalpha() or lckey.startswith('_'):
|
if lckey[0:1].isalpha() or lckey.startswith('_'):
|
||||||
lckey = chr(127) + lckey
|
lckey = chr(127) + lckey
|
||||||
# ensure a determinstic order *within* letters by also sorting on
|
# ensure a determinstic order *within* letters by also sorting on
|
||||||
@ -163,6 +165,8 @@ class IndexEntries(EnvironmentManager):
|
|||||||
v[1] = sorted((si, se) for (si, (se, void, void)) in iteritems(v[1]))
|
v[1] = sorted((si, se) for (si, (se, void, void)) in iteritems(v[1]))
|
||||||
if v[2] is None:
|
if v[2] is None:
|
||||||
# now calculate the key
|
# now calculate the key
|
||||||
|
if k.startswith(u'\N{RIGHT-TO-LEFT MARK}'):
|
||||||
|
k = k[1:]
|
||||||
letter = unicodedata.normalize('NFD', k[0])[0].upper()
|
letter = unicodedata.normalize('NFD', k[0])[0].upper()
|
||||||
if letter.isalpha() or letter == '_':
|
if letter.isalpha() or letter == '_':
|
||||||
return letter
|
return letter
|
||||||
|
Loading…
Reference in New Issue
Block a user