diff --git a/docs/options.md b/docs/options.md index a83af81..4868c58 100644 --- a/docs/options.md +++ b/docs/options.md @@ -9,6 +9,7 @@ plugins: print_page_title: 'Print Site' add_table_of_contents: true toc_title: 'Table of Contents' + toc_depth: 6 add_full_urls: false enumerate_headings: true enumerate_figures: true @@ -29,6 +30,9 @@ plugins: `toc_title` : Default is `'Table of Contents'`. When `add_table_of_contents` is set to `true` this setting controls the name of the table of contents. This setting is ignored when `add_table_of_contents` is set to `false`. +`toc_depth` +: Default is `6`. When `add_table_of_contents` is set to `true` this setting controls the depth of the table of contents. This setting is ignored when `add_table_of_contents` is set to `false`. + `add_full_urls` : Default is `false`. When printing a page, you cannot see the target of a link. This option adds the target url in parenthesis behind a link. diff --git a/mkdocs.yml b/mkdocs.yml index 4ad6753..06a2080 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,6 +13,8 @@ plugins: add_full_urls: false add_table_of_contents: true toc_title: "Table of Contents" + toc_depth: 2 + add_full_urls: false enumerate_headings: true enumerate_figures: true add_cover_page: true @@ -72,7 +74,7 @@ markdown_extensions: - pymdownx.tilde - pymdownx.smartsymbols - toc: - permalink: true + permalink: ↵ extra_javascript: - javascripts/config.js diff --git a/mkdocs_print_site_plugin/js/print-site.js b/mkdocs_print_site_plugin/js/print-site.js index 80cdfb8..8e38069 100644 --- a/mkdocs_print_site_plugin/js/print-site.js +++ b/mkdocs_print_site_plugin/js/print-site.js @@ -26,6 +26,9 @@ function generate_toc() { var current_section_depth = 0; var inserted_padding_row = false; + // Extract table of contents depth + var toc_depth = document.getElementById("print-page-toc").getAttribute("data-toc-depth") + for (var i = 0; i < toc_elements.length; i++) { @@ -62,6 +65,11 @@ function generate_toc() { tag = el.tagName tag_level = tag.substring(1) + // print-site-plugin has a setting to control TOC depth + if ( tag_level > toc_depth ) { + continue; + } + while (tag_level > current_heading_depth) { current_heading_depth++; ToC += "