diff --git a/pygameweb/templates/wiki/view.html b/pygameweb/templates/wiki/view.html index a717792..9a43748 100644 --- a/pygameweb/templates/wiki/view.html +++ b/pygameweb/templates/wiki/view.html @@ -9,121 +9,86 @@ {% cache 60*5, 'wiki_content', link %} {% set wiki = wiki_for(link) %} {% set content_rendered, toc_rendered = wiki.content_toc %} - {% if toc_rendered %} +
- {{ toc_rendered | safe }} +
+ {% if toc_rendered %} + {{ toc_rendered | safe }} + {% endif %} + + +
- {% endif %} -

{{ wiki.title }} — wiki

- - -
{{ content_rendered | safe }}
- - {% if toc_rendered %}
- {% endif %} - {% endcache %} {% endblock %} -{# - Use a nicer side bar table of contents navigation component. - https://afeld.github.io/bootstrap-toc/ -#} - - - {% block body_attribs %}{{ super() }}{% endblock body_attribs %} {%- block styles %} {{ super() }} -{% endblock %} -{%- block scripts %} - {{ super() }} - {% endblock %} \ No newline at end of file diff --git a/pygameweb/wiki/wiki.py b/pygameweb/wiki/wiki.py index e402dd4..82a35e4 100644 --- a/pygameweb/wiki/wiki.py +++ b/pygameweb/wiki/wiki.py @@ -169,12 +169,20 @@ def table_of_contents(pq_content): # for i, heading in enumerate(pq_content.find('h1,h2,h3,h4')): for i, heading in enumerate(pq_content.find('h1,h2,h3,h4')): title = pq(heading).text() - pq(heading).attr('id', title) + header_link = (pq('ΒΆ') + .addClass('header_link') + .attr('href', '#' + title) + ) + (pq(heading) + .attr('id', title) + .addClass('wiki-heading') + .append(header_link)) + link = (pq('') - .text(title) - .attr('href', '#' + title) - .addClass('li' + heading.tag) - .wrap('
  • ')) + .text(title) + .attr('href', '#' + title) + .addClass('li' + heading.tag) + .wrap('
  • ')) if heading.tag in ['h1', 'h2']: previous_heading = heading diff --git a/tests/unit/pygameweb/wiki/test_wiki.py b/tests/unit/pygameweb/wiki/test_wiki.py index 201354d..5a5a26f 100644 --- a/tests/unit/pygameweb/wiki/test_wiki.py +++ b/tests/unit/pygameweb/wiki/test_wiki.py @@ -110,8 +110,8 @@ def test_wiki_section(): """ res = _wiki_section(content).outerHtml() - assert '

    ' in res, 'because headers should have an id' - assert '

    ' in res + assert '

    And finally the last one

    """ res = _wiki_section(content).outerHtml() - assert '

    ' in res, 'because headers should have an id' - assert '

    ' in res + assert '