mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5070: epub: Wrong internal href fragment links
This commit is contained in:
parent
e1a87ba073
commit
d7bf78f3ff
1
CHANGES
1
CHANGES
@ -31,6 +31,7 @@ Bugs fixed
|
|||||||
* #5036: quickstart: Typing Ctrl-U clears the whole of line
|
* #5036: quickstart: Typing Ctrl-U clears the whole of line
|
||||||
* #5066: html: "relations" sidebar is not shown by default
|
* #5066: html: "relations" sidebar is not shown by default
|
||||||
* #5091: latex: curly braces in index entries are not handled correctly
|
* #5091: latex: curly braces in index entries are not handled correctly
|
||||||
|
* #5070: epub: Wrong internal href fragment links
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -271,6 +271,16 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
node['refuri'] = self.fix_fragment(m.group(1), m.group(2))
|
node['refuri'] = self.fix_fragment(m.group(1), m.group(2))
|
||||||
if 'refid' in node:
|
if 'refid' in node:
|
||||||
node['refid'] = self.fix_fragment('', node['refid'])
|
node['refid'] = self.fix_fragment('', node['refid'])
|
||||||
|
for node in tree.traverse(nodes.target):
|
||||||
|
for i, node_id in enumerate(node['ids']):
|
||||||
|
if ':' in node_id:
|
||||||
|
node['ids'][i] = self.fix_fragment('', node_id)
|
||||||
|
|
||||||
|
next_node = node.next_node(siblings=True)
|
||||||
|
if next_node and isinstance(next_node, nodes.Element):
|
||||||
|
for i, node_id in enumerate(next_node['ids']):
|
||||||
|
if ':' in node_id:
|
||||||
|
next_node['ids'][i] = self.fix_fragment('', node_id)
|
||||||
for node in tree.traverse(addnodes.desc_signature):
|
for node in tree.traverse(addnodes.desc_signature):
|
||||||
ids = node.attributes['ids']
|
ids = node.attributes['ids']
|
||||||
newids = []
|
newids = []
|
||||||
|
11
tests/roots/test-epub-anchor-id/conf.py
Normal file
11
tests/roots/test-epub-anchor-id/conf.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
master_doc = 'index'
|
||||||
|
|
||||||
|
latex_documents = [
|
||||||
|
(master_doc, 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
app.add_crossref_type(directivename="setting", rolename="setting")
|
8
tests/roots/test-epub-anchor-id/index.rst
Normal file
8
tests/roots/test-epub-anchor-id/index.rst
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
test-epub-anchor-id
|
||||||
|
===================
|
||||||
|
|
||||||
|
.. setting:: STATICFILES_FINDERS
|
||||||
|
|
||||||
|
blah blah blah
|
||||||
|
|
||||||
|
see :setting:`STATICFILES_FINDERS`
|
@ -317,6 +317,15 @@ def test_epub_writing_mode(app):
|
|||||||
assert 'writing-mode: vertical-rl;' in css
|
assert 'writing-mode: vertical-rl;' in css
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('epub', testroot='epub-anchor-id')
|
||||||
|
def test_epub_anchor_id(app):
|
||||||
|
app.build()
|
||||||
|
|
||||||
|
html = (app.outdir / 'index.xhtml').text()
|
||||||
|
assert '<p id="std-setting-STATICFILES_FINDERS">blah blah blah</p>' in html
|
||||||
|
assert 'see <a class="reference internal" href="#std-setting-STATICFILES_FINDERS">' in html
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('epub')
|
@pytest.mark.sphinx('epub')
|
||||||
def test_run_epubcheck(app):
|
def test_run_epubcheck(app):
|
||||||
app.build()
|
app.build()
|
||||||
|
Loading…
Reference in New Issue
Block a user