remarkjs / remark-toc

plugin to generate a table of contents (TOC)

Home Page:https://remark.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can this be configured in a .remarkrc file?

ndelangen opened this issue · comments

The documentation mentions how to configure with the programmatic API, but not the config-file api.

How do I configure this in my .remarkrc file?

Here's my .remarkrc file:

{
  "plugins": [
    "remark-preset-lint-recommended",
    ["remark-toc", {
      "tight": true,
      
    }],
    ["remark-lint-list-item-indent", false],
    ["remark-lint-code", {"js": {
      "module": "node_modules/remark-lint-code-eslint",
      "options": {
        "fix": true
      }
    }}]
  ]
}
commented

You’re already using it right!?

But it's not actually adding the tocs..

What could I be doing wrong?

commented

How are you running remark? Tip: add the DEBUG env variable.

commented

In remark . # -- -o to update, the # makes the rest of the line into a comment, if you want to generate files, you do need to pass -o, --output, like so: remark . -o!

I know, I'm actually running this:
npm run lint:markdown -- -o

commented

Is any markdown reformatted? Maybe -- -o isn't the proper way to pass flags?

No it appears no markdown is formatted, strange that was working before..

commented

New npm version? I’m note sure, but I think they switched it around before.
So is it working now?

So it DOES work when I change my npm script like so:
"lint:markdown": "DEBUG=\"*\" remark . -o",

commented

Maybe because of the comment? Maybe npm execs like so: remark . # -- -o to update -o (where the last -o is added from outside the npm script).

I guess it could be because of the comment, yeah, I'll reset, and try without 👍

remark-toc is adding the tocs correctly now, thanks. 😎

I will stop adding comments to my npm script and dislike json for configuring even more 😒

commented

😛

Alright, good! Feel free to add more issues if you run into stuff, but I’d also like to point out that the Gitter channel is really good for more question-like stuff!