mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #6007 from tk0miya/5871_fix_texinfo_period
Allow periods in texinfo node names
This commit is contained in:
commit
a8777f6c01
1
CHANGES
1
CHANGES
@ -34,6 +34,7 @@ Bugs fixed
|
||||
:file:`parskip.sty`
|
||||
* #5958: versionadded directive causes crash with Python 3.5.0
|
||||
* #5995: autodoc: autodoc_mock_imports conflict with metaclass on Python 3.7
|
||||
* #5871: texinfo: a section title ``.`` is not allowed
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -384,9 +384,12 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
def escape_id(self, s):
|
||||
# type: (unicode) -> unicode
|
||||
"""Return an escaped string suitable for node names and anchors."""
|
||||
bad_chars = ',:.()'
|
||||
bad_chars = ',:()'
|
||||
for bc in bad_chars:
|
||||
s = s.replace(bc, ' ')
|
||||
if re.search('[^ .]', s):
|
||||
# remove DOTs if name contains other characters
|
||||
s = s.replace('.', ' ')
|
||||
s = ' '.join(s.split()).strip()
|
||||
return self.escape(s)
|
||||
|
||||
|
@ -15,10 +15,12 @@ import re
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
import pytest
|
||||
from mock import Mock
|
||||
from six import PY3
|
||||
from test_build_html import ENV_WARNINGS
|
||||
|
||||
from sphinx.testing.util import remove_unicode_literals, strip_escseq
|
||||
from sphinx.util.docutils import new_document
|
||||
from sphinx.writers.texinfo import TexinfoTranslator
|
||||
|
||||
|
||||
@ -93,3 +95,20 @@ def test_texinfo_citation(app, status, warning):
|
||||
'This is a citation\n') in output
|
||||
assert ('@anchor{index cite2}@anchor{2}@w{(CITE2)} \n'
|
||||
'This is a multiline citation\n') in output
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo_escape_id(app, status, warning):
|
||||
settings = Mock(title='',
|
||||
texinfo_dir_entry='',
|
||||
texinfo_elements={})
|
||||
document = new_document('', settings)
|
||||
translator = app.builder.create_translator(document, app.builder)
|
||||
|
||||
assert translator.escape_id('Hello world') == 'Hello world'
|
||||
assert translator.escape_id('Hello world') == 'Hello world'
|
||||
assert translator.escape_id('Hello Sphinx world') == 'Hello Sphinx world'
|
||||
assert translator.escape_id('Hello:world') == 'Hello world'
|
||||
assert translator.escape_id('Hello(world)') == 'Hello world'
|
||||
assert translator.escape_id('Hello world.') == 'Hello world'
|
||||
assert translator.escape_id('.') == '.'
|
||||
|
Loading…
Reference in New Issue
Block a user