technote-space / toc-generator

GitHub Actions to generate TOC (Table of Contents)
MIT License
224 stars 29 forks source link

<!-- DOCTOC SKIP --> doesn't work #371

Closed DougLeonard closed 1 year ago

DougLeonard commented 1 year ago

Describe the bug

Files with \ at top are not skipped.

To Reproduce

1) add a markdown file like Home.md with \ as the first line

2) use following for .github/workflows/toc.yml:

on: push
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4
        with:
          TARGET_PATHS: "."

3) push to github
4) TOCs are added to all .md files, including Home.md

Expected behavior:

A TOC is not automatically added to Home.md

Additional context:

running

doctoc .

from the local clone produces the expected behavior, indicating that the comment tag is inserted correctly.
Maybe there is a difference is doctoc versions? Or I'm doing it wrong?

Edited toc.yml above, tested with both v3 and v4.

welcome[bot] commented 1 year ago

:raised_hands: Thanks for opening your first issue here! Be sure to follow the issue template!

DougLeonard commented 1 year ago

I'm just learning my way around github actions. So I found a simple enough solutions by just rolling my own workflow instead.

A draft of that looks like this:

on: push
name: TOC Action

jobs:
  doDOCTOC:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Install dependencies
        run: |
           npm install -g doctoc

      - name: Run DODCTOC
        run: |
           doctoc .

      - name: Commit
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Auto update markdown TOC

It's slow, isn't using lockfile caching, but it does work, and it does ignore \ as expected.