From b9354cc136584f83348ca2140b5ff867eea89857 Mon Sep 17 00:00:00 2001 From: Alexandre Chapellon Date: Wed, 4 Dec 2024 23:04:07 +0100 Subject: [PATCH] add more options --- .github/actions/md-toc/action.yml | 10 +++++++++- docs/README.md | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/actions/md-toc/action.yml b/.github/actions/md-toc/action.yml index c236ae9e8..1312100ee 100644 --- a/.github/actions/md-toc/action.yml +++ b/.github/actions/md-toc/action.yml @@ -26,6 +26,12 @@ inputs: description: Bullets to use for Table of Contents ("*", "-" or "+") required: false default: '*' + no_toc_in_toc: + description: >- + Do not include Table of Contents heading in Table of Contents + (Assuming it's the first h1/##) + required: false + default: 'true' node_version: description: Node.js version to install (false means do not install) required: false @@ -43,8 +49,10 @@ runs: - name: Generate Table of Contents env: MDTOC_IARG: ${{ inputs.dry_run == 'false' && '-i' || '' }} + MDTOC_HARG: ${{ inputs.no_toc_in_toc == 'true' && '--no-firsth1' || '' }} + MDTOC_ARGS: ${{ env.MDTOC_IARG }} ${{ env.MDTOC_HARG }} run: | - markdown-toc "$MDTOC_IARG" \ + markdown-toc "$MDTOC_ARGS" \ --maxdepth "${{ inputs.depth }}" \ --bullets "${{ inputs.bullets }}" \ --append "${{ inputs.append }}" \ diff --git a/docs/README.md b/docs/README.md index e6ff2f10b..07c2eddcf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1681,9 +1681,13 @@ Generates a Markdown table of contents for a file. For ToC to be inserted in your file, it needs to contain the HTML comment below: ```markdown +## Table of Contents ``` +> If you do not add an H1 tag as show above before the ToC comment, use `no_toc_in_toc: false` with this action +> otherwise it will skip the first paragraph of the file. + ### update-deployment-runtime-versions For more information, see [update-deployment-runtime-versions](../.github/actions/update-deployment-runtime-versions/action.yml).