Package: unicode_ids
NoteJapanese version of this document is also available, on thesiteor the doc
folder of this package.IntroductionCurrently, June 3, 2015, Sphinx 1.3.1 generates ‘id’ attributes
in HTML without Non-ASCII characters. This behavior is requirement
of HTML4.01.But today, these characters can be usable with latest web browsers
and HTML5 specification.Also, the Sphinx replaces non-ASCII URLs into ASCII only with
imcompatible way against current web standards.This extension fixes both problems above at every runtime.
The patchs is applied to both docutils and Sphinx to make ideal
behavior.License2-clause BSD, same as the Sphinx project.InstallationYou can install or uninstall this package like another Python packages.
Also, you can use this package without installing this package on your Python
systems, the configuration file of Sphinx(conf.py) enable you to use.System requirementsTested with 32bit version of Python 2.7.10 and 64bit version of 3.4.3,
both on the Microsoft Windows 8.1 Pro 64bit edition. But with another
versions and on another OSs would be usable.Python 3 is required if you need full unicode support.
When used with Python 2, the usable character set is limited
with local encoding.There’s a thing important to know: This extension depends on both
docutils 0.12 and Sphinx 1.3.1. The patching is usableUNTILthe
some functions keep same as ones on these versions.How to installYou can install this package as you will do with another one.Open a console and dopip install unicode_ids.On the MS-Windows,<python_installed_path>\Scripts\pip.exe install unicode_ids.Or when you get zip archive likeunicode_ids-2.0.5(.zip)where ‘2.0.5’ is version number,
change current directiory to the folder that has the zip file,
and dopip install unicode_ids-2.0.5.zip.On the MS-Windows,<python_installed_path>\Scripts\pip.exe install unicode_ids-2.0.5.zip.Or, this way is the Sphinx specific, you can use this package just extracted
any folder you want. theconf.pyenables you to use the themes and
extensions.How to useAs another extensions, you can use this extension by editingconf.py.First, you should add:# add 3 lines belowimportdistutils.sysconfigsite_package_path=distutils.sysconfig.get_python_lib()sys.path.insert(0,os.path.join(site_package_path,'sphinxcontrib/unicode_ids'))Or, when you don’t install with pip or like,# add just 1 line belowsys.path.insert(0,'<path_to_the_folder_contains_unicode_ids_py>')Next, add unicode_ids extension intoextensionlist:extension=['unicode_ids',]# Of course you can add another extensions.How to know Unicode is acceptable with identifiersThis section is written at 2015-06-03(JST, UTC+9).URI general with HTMLHTML4.01[HTML401]restricts usable charactersA-Za-z0-9_:.and hypen-. But also recommends how to do withB.2.1 Non-ASCII characters in URI attribute values.By transforming as told at the section, the URIs consist of
ASCII 7 bit characters only. In the HTML4.01, we should always
UTF-8 to encode/decode URIs, but also be noted some old documents
may expect another local encoding to encode/decode.HTML5[HTML5][HTML51]specification has the section2.5 URLs.
The section shows more complex way to determine the encodings.
When the URL is given with local encodings or source documents are
encoded with local encoding, we should use that one instead of UTF-8.Considering both specifications, we should always make HTML files with
UTF-8 encoded, to make clear percent hexadecimal arrays represent unicode
string transformed by UTF-8.There’re another standards, W3C URL[W3CURL]and
WHATWG URL Living Standard[WHATWGURL].
They also defines URL code units, URL code points and percent-encoded bytes.
They say the percent-encoded bytes should represent UTF-8 sequences.Identifiers (anchors) on HTMLHTML5 defines ‘id’ attribute(see3.2.5.1 The id attribute) as
theunique identifier.In the explanation of the word ‘DOM’ described the2.2.2 Dependenciessection, you can know ‘The concept of an element's unique
identifier (ID)’ is one of the ‘features are defined in the
DOM specification’.In DOM4[DOM4],5.8 Interface Elementdefines the ‘id’ attribute asDOMStringand the
specification says theElements can have an associated unique
identifier (ID).As described at9 Historical/9.2 DOM Core,DOMStringis now
‘defined in Web IDL’.With W3C WebIDL[WebIDL]at3.10.15 DOMStringsection,
the DOMString is defined as a sequence of code units.
Thecode unitis also defined on the WebIDL as a 16 bit unsigned integer,
and is corresponding to UTF-16 encoding.As shown, we can know the IDs of the HTML elements can be
written with unicode characters. That can be considered
UTF-16 encoded internally. Note that current CSS3 does not
allow starting with digits, two hyphens or a hyphen followed
by a digit(see next section).Note that DOM3 definesDOMStringat DOM3CORE[DOM3CORE],
see the section1.2.1 The DOMString Type.Identifiers on CSSCascading Style Sheet(CSS) is now level 3. Starts from CSS3, the stability is
defined module by module which are defined CSS 2.1.(see
the1.1 Introductionsection of
CSS Snapshot 2010[CSSSnapshot].On CSS2.1[CSS21][CSS22]4.1.3 Characters and casesection
shows the set of the characters we can use to define identifiers.
The 2nd paragraph says:In CSS, identifiers (including element names, classes, and IDs in selectors)
can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0
and higher, plus the hyphen (-) and the underscore (_); they cannot start
with a digit, two hyphens, or a hyphen followed by a digit …(snip)As shown above, we can use Non-ASCII characters for identifiers. ISO 10646 is
almost same with Unicode. And currently, CSS3 seems to use same definition for
the identifiers.Identifiers on JavaScript/ECMAScriptECMAScript[ECMAScript]is the name of global standard of JavaScript, roughly to say :)In the specification of the ECMAScript, the section7.6 Identifier Names
and Identifiersshows usable characters for identifiers.The section clearly allows use Unicode characters. It seems some character
group are not able to use, but in fact, the rule contains ‘Unicode escape
sequence’. This means finally any character we can use.Related productssphinx_html5_basic_themeAuthorSuzumizaki-Kimitaka, 2011-2015History2.0.5(2015-07-04):Extracted alone fromYogosyuextension.First uploaded to PyPI.2013-12-07:Add Python 3 support.2013-12-06:updated to meet Sphinx 1.2.2011-05-24:First release. Included inYogosyuextension.References[HTML401]HTML 4.01,1999-12-24REC[HTML5]HTML 5,2014-10-28REC[HTML51]HTML 5.1,2015-05-06WD[W3CURL]W3C URL,2015-12-09WD[WHATWGURL]WHATWG URL Living Standard[DOM4]W3C DOM 4,2015-04-28LC[WebIDL](W3C) WebIDL,2012-04-19CR[DOM3CORE]DOM Level 3 Core,2004-04-07REC[CSSSnapshot]CSS Snapshot 2010,2011-05-12NOTE[CSS21]CSS 2.1,2011-06-07REC[CSS22]CSS 2.2, 2015-05-28WD(only permalink is broken)[ECMAScript]ECMAScript 5.1