diff --git a/CHANGES b/CHANGES index bd93d0f53..1730f3b32 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,8 @@ Bugs fixed * #4223: doctest: failing tests reported in wrong file, at wrong line * i18n: message catalogs are not compiled if specific filenames are given for ``sphinx-build`` as arguments (refs: #4560) +* #4027: sphinx.ext.autosectionlabel now expects labels to be the same as they + are in the raw source; no smart quotes, nothig fancy. Testing -------- diff --git a/sphinx/ext/autosectionlabel.py b/sphinx/ext/autosectionlabel.py index bebbaa69c..a5e22dfd5 100644 --- a/sphinx/ext/autosectionlabel.py +++ b/sphinx/ext/autosectionlabel.py @@ -30,9 +30,10 @@ def register_sections_as_label(app, document): labelid = node['ids'][0] docname = app.env.docname if app.config.autosectionlabel_prefix_document: - name = nodes.fully_normalize_name(docname + ':' + node[0].astext()) + name = nodes.fully_normalize_name( + docname + ':' + node[0].rawsource) else: - name = nodes.fully_normalize_name(node[0].astext()) + name = nodes.fully_normalize_name(node[0].rawsource) sectname = clean_astext(node[0]) if name in labels: diff --git a/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst b/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst index a608c5b51..10fa2662d 100644 --- a/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst +++ b/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst @@ -15,6 +15,9 @@ For Windows users For UNIX users -------------- +This one's got an apostrophe +---------------------------- + References ========== @@ -23,3 +26,4 @@ References * :ref:`index:Installation` * :ref:`index:For Windows users` * :ref:`index:For UNIX users` +* :ref:`index:This one's got an apostrophe` diff --git a/tests/roots/test-ext-autosectionlabel/index.rst b/tests/roots/test-ext-autosectionlabel/index.rst index ac96e5cf5..bf8818fa0 100644 --- a/tests/roots/test-ext-autosectionlabel/index.rst +++ b/tests/roots/test-ext-autosectionlabel/index.rst @@ -15,6 +15,9 @@ For Windows users For UNIX users -------------- +This one's got an apostrophe +---------------------------- + References ========== @@ -23,3 +26,4 @@ References * :ref:`Installation` * :ref:`For Windows users` * :ref:`For UNIX users` +* :ref:`This one's got an apostrophe` diff --git a/tests/test_ext_autosectionlabel.py b/tests/test_ext_autosectionlabel.py index 1266edbc3..b2b3685d8 100644 --- a/tests/test_ext_autosectionlabel.py +++ b/tests/test_ext_autosectionlabel.py @@ -35,6 +35,12 @@ def test_autosectionlabel_html(app, status, warning): 'For UNIX users') assert re.search(html, content, re.S) + html = ('