diff --git a/setup.py b/setup.py index 4dd9e99..58e6e59 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setuptools.setup( name='sphinxprettysearchresults', packages=['sphinxprettysearchresults'], - version='0.1.5', + version='0.1.6', description='Decently styled search results for sphinx-doc projects', author='Timotheus Kampik', author_email='timotheus.kampik@gmail.com', diff --git a/sphinxprettysearchresults/__init__.py b/sphinxprettysearchresults/__init__.py index 1ee407f..caf6163 100644 --- a/sphinxprettysearchresults/__init__.py +++ b/sphinxprettysearchresults/__init__.py @@ -1,7 +1,9 @@ -import os, shutil, subprocess -import docutils.nodes +import shutil, subprocess +import docutils -from docutils.nodes import table, header, image, figure, title, emphasis, strong +from docutils import nodes + +from docutils.nodes import * def clean_txts(language, srcdir, outdir): @@ -41,13 +43,18 @@ def remove_text_markup(app, doctree, docname): + doctree.traverse(header)\ + doctree.traverse(title)\ + doctree.traverse(emphasis)\ - + doctree.traverse(strong) + + doctree.traverse(strong) \ + + doctree.traverse(list_item) \ + + doctree.traverse(reference) for node in nodes_to_replace: - newnode = docutils.nodes.line('', node.astext()) + newnode = paragraph() + newnode.append(line('', node.astext())) node.replace_self(newnode) nodes_to_remove = doctree.traverse(figure)\ - + doctree.traverse(image) + + doctree.traverse(image)\ + + doctree.traverse(compound) + for node in nodes_to_remove: node.replace_self(docutils.nodes.line('','')) diff --git a/tests/root/index.rst b/tests/root/index.rst index 87764b5..0ccb402 100644 --- a/tests/root/index.rst +++ b/tests/root/index.rst @@ -23,3 +23,22 @@ Lorem ipsum .. image:: test.png :alt: image + +* list item star + +- list item dash + +1. list item number + +#. list item auto number + +.. glossary:: + + term1 + term1 definition + +:term:`term1` + +.. toctree:: + + toctree_item \ No newline at end of file diff --git a/tests/root/toctree_item.rst b/tests/root/toctree_item.rst new file mode 100644 index 0000000..27c7907 --- /dev/null +++ b/tests/root/toctree_item.rst @@ -0,0 +1,2 @@ +toctree_item +============ \ No newline at end of file diff --git a/tests/test_remove_markup.py b/tests/test_remove_markup.py index 5686120..2be4c8b 100644 --- a/tests/test_remove_markup.py +++ b/tests/test_remove_markup.py @@ -37,4 +37,19 @@ def test_image(): def test_table(): assert lines[12] == ' cell1/1 cell1/2 cell2/1 cell2/2', '%s !=\ - " cell1/1 cell1/2 cell2/1 cell2/2"' % (lines[10]) \ No newline at end of file + " cell1/1 cell1/2 cell2/1 cell2/2"' % (lines[10]) + + +def test_toc(): + assert any('toctree_item' in line for line in lines) == False, '"toctree_item" is in line in lines' + + +def test_list_item(): + assert lines[15] == 'list item star', '%s != "list item star"' % (lines[15]) + assert lines[17] == 'list item dash', '%s != "list item dash"' % (lines[17]) + assert lines[19] == 'list item number', '%s != "list item number"' % (lines[19]) + assert lines[21] == 'list item auto number', '%s != "list item auto number"' % (lines[21]) + + +def test_term(): + assert lines[26] == 'term1', '%s != "Level 1 Heading"' % (lines[26]) \ No newline at end of file