mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #185: References to section title including raw node has broken
This commit is contained in:
parent
71124bb50c
commit
3b9aee43a2
1
CHANGES
1
CHANGES
@ -13,6 +13,7 @@ Bugs fixed
|
||||
* #3246: xapian search adapter crashes
|
||||
* #3253: In Py2 environment, building another locale with a non-captioned
|
||||
toctree produces ``None`` captions
|
||||
* #185: References to section title including raw node has broken
|
||||
|
||||
Release 1.5.1 (released Dec 13, 2016)
|
||||
=====================================
|
||||
|
@ -216,6 +216,8 @@ def clean_astext(node):
|
||||
node = node.deepcopy()
|
||||
for img in node.traverse(nodes.image):
|
||||
img['alt'] = ''
|
||||
for raw in node.traverse(nodes.raw):
|
||||
raw.parent.remove(raw)
|
||||
return node.astext()
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ from docutils.parsers import rst
|
||||
from docutils.utils import new_document
|
||||
from docutils import frontend
|
||||
|
||||
from sphinx.util.nodes import extract_messages
|
||||
from sphinx.util.nodes import extract_messages, clean_astext
|
||||
from sphinx.transforms import ApplySourceWorkaround
|
||||
|
||||
|
||||
@ -150,3 +150,15 @@ def test_extract_messages_without_rawsource():
|
||||
_transform(document)
|
||||
assert_node_count(extract_messages(document), nodes.TextElement, 1)
|
||||
assert [m for n, m in extract_messages(document)][0], 'text sentence'
|
||||
|
||||
|
||||
def test_clean_astext():
|
||||
node = nodes.paragraph(text='hello world')
|
||||
assert 'hello world' == clean_astext(node)
|
||||
|
||||
node = nodes.image(alt='hello world')
|
||||
assert '' == clean_astext(node)
|
||||
|
||||
node = nodes.paragraph(text='hello world')
|
||||
node += nodes.raw('', 'raw text', format='html')
|
||||
assert 'hello world' == clean_astext(node)
|
||||
|
Loading…
Reference in New Issue
Block a user