confluencebuilder icon indicating copy to clipboard operation
confluencebuilder copied to clipboard

generate in-page toc

Open danieltuzes opened this issue 3 years ago • 2 comments

this is a feature request

Please add the option to generate TOC (using confluence's toc macro) within a page given a heading structure. It also helps to create deeplinks. If it is available. please improve the documentation so that this info can be found easier.

danieltuzes avatar May 18 '22 12:05 danieltuzes

The Table of Contents Macro macro does not have a directive support yet, but we can plan to add a confluence_toc directive type in attempt to support this.

At this time, a workaround would be to add something like this to use Confluence's TOC macro:

(default)

.. raw:: confluence_storage

    <ac:structured-macro ac:name="toc" ac:schema-version="1" />

(parameter examples; see Confluence's TOC tree macro for more macro options)

.. raw:: confluence_storage

    <ac:structured-macro ac:name="toc" ac:schema-version="1">
        <ac:parameter ac:name="maxLevel">6</ac:parameter>
        <ac:parameter ac:name="minLevel">2</ac:parameter>
        <ac:parameter ac:name="outline">true</ac:parameter>
        <ac:parameter ac:name="type">flat</ac:parameter>
    </ac:structured-macro>

To my own understanding, Confluence's TOC tree macro is for local page header/TOC only. I believe a matching reStructuredText equivalent would be the use of the contents directive, such as follows:

.. contents::
    :local:

This will provide support for things like backlinks; but will not have capabilities such as Confluence flat-type TOCs.

jdknight avatar May 19 '22 03:05 jdknight

Initial support has been introduced (#660) to support Confluence's Table of Contents macros through Sphinx-supported directives. This change has been added into the main branch and should be made available next stable release. If users wish to use this capability before a release is made, the development version of this extension can be installed.

jdknight avatar May 28 '22 22:05 jdknight

v1.9 is now available on PyPI -- marking as closed.

jdknight avatar Aug 21 '22 18:08 jdknight