{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2021-04-21T15:49:38Z","object_id":{"id":1296,"is_a":["text","documentation","reference","module"],"name":"doc_module_mod_base","title":"mod_base","uri":"https:\/\/zotonic.com\/id\/1296"},"seq":1000000}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"subject":{"objects":[{"created":"2026-09-09T13:47:57Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:47:57Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-09T13:47:57Z","object_id":{"id":2621,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template_filter","title":"Template filter","uri":"https:\/\/zotonic.com\/id\/2621"},"seq":3},{"created":"2026-09-09T13:47:57Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":4},{"created":"2026-09-09T13:47:57Z","object_id":{"id":2672,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_html","title":"HTML","uri":"https:\/\/zotonic.com\/id\/2672"},"seq":5}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2250,"is_a":["text","documentation","reference","template_filter"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2250"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_template_filter_filter_toc","page_url":{"en":"https:\/\/zotonic.com\/docs\/2250\/toc","x-default":"https:\/\/zotonic.com\/docs\/2250\/toc"},"preview_url":null,"resource":{"version":2787,"pivot_location_lat":null,"title":"toc","is_authoritative":true,"body":"<p>Filter to derive a Table Of Contents from a HTML body.<\/p>\n<p>This filter extracts a nested table of contents from the h2..h6 elements in a HTML text.<\/p>\n<p>The headers may not have any attributes (ie. only <code>&lt;h2&gt;<\/code>).<\/p>\n<p>All sections are wrapped in <code>&lt;div&gt;<\/code> elements, this to make it possible to make the headers sticky without having them overlap.<\/p>\n<p>Example usage:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% with id.body|toc as toc, body %}\n    {% include &quot;page-parts\/_toc.tpl&quot; toc=toc %}\n    {{ body|show_media }}\n{% endwith %}\n<\/code><\/pre>\n<p>An optional minimum number of headers suppresses the table of contents for\nshort texts. The processed body is returned with header anchors regardless of\nwhether the table of contents is suppressed:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% with id.body|toc:4 as toc, body %}\n    {% include &quot;page-parts\/_toc.tpl&quot; toc=toc %}\n    {{ body|show_media }}\n{% endwith %}\n<\/code><\/pre>\n<p>The returned ToC tree is a nested tree of 3-tuples:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">[ {&lt;&lt;&quot;toc1&quot;&gt;&gt;, &lt;&lt;&quot;Text of header&quot;&gt;&gt;, [ ... ]}, ... ]\n<\/code><\/pre>\n<p>The third element is a list of sub-headers.<\/p>\n<p>To generate a nested table of contents from the above structure:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% include &quot;page-parts\/_toc.tpl&quot; toc=toc %}\n<\/code><\/pre>\n<p>And then the <code>page-parts\/_toc.tpl<\/code> as:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% with level|default:1 as level %}\n{% if toc %}\n    &lt;ol class=&quot;toc-level-{{ level }}&quot;&gt;\n    {% for p, text, sub in toc %}\n        &lt;li&gt;\n            &lt;a href=&quot;#{{ p }}&quot;&gt;{{ text }}&lt;\/a&gt;\n            {% include &quot;page-parts\/_toc.tpl&quot; toc=sub level=level+1 %}\n        &lt;\/li&gt;\n    {% endfor %}\n    &lt;\/ol&gt;\n{% endif %}\n{% endwith %}\n<\/code><\/pre>","slug":"toc","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"3b91e00681563d55744d4e0a5385bad895aa96634c46093ce1563516a79ee9a5","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":325,"is_a":["meta","category"],"name":"template_filter","title":"Filters","uri":"https:\/\/test.zotonic.com\/id\/325"},"doc_source_path":"apps\/zotonic_mod_base\/src\/filters\/filter_toc.erl","publication_start":"2023-06-24T08:17:54Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_mod_base\/src\/filters\/filter_toc.erl","pivot_location_lng":null,"doc_source_kind":"filter","name":"doc_template_filter_filter_toc","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2021-04-21T15:49:21Z","uri":null,"doc_status":"current","is_dependent":false,"erlang_app":"zotonic_mod_base","publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"28493fb676b2d92727e68d4fba20d89c56cf8ead\n","erlang_module":"filter_toc","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-15T20:07:28Z","title_slug":"toc"},"uri":"https:\/\/zotonic.com\/id\/2250","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2250"}},"status":"ok"}