marksman icon indicating copy to clipboard operation
marksman copied to clipboard

Add indentation configuration

Open tukusejssirs opened this issue 2 years ago • 1 comments

Ideally, marksman should follow the indentation config of the editor (or currently open file or .editorconfig), however, when that does not work, users should be able to configure indentation via, e.g., indent property which could be either tab string or a number (how many spaces should be used for indentation).

~~Now, I have configured indentation to three spaces in Markdown files, however, the generated TOC looks like this:~~ Actually, this was my mistake, as I actually used heading levels 1, 3, 4, and 3 instead of 1, 2, 3, 2).

example of my mistake
<!--toc:start-->
- [Heading 1]()
      - [Heading 2]()  <!-- 6 spaces -->
        - [Heading 3]()  <!-- 8 spaces -->
      - [Heading 2]()  <!-- 6 spaces -->
<!--toc:end-->

I would expect it to be as follows:

<!--toc:start-->
- [Heading 1]()
   - [Heading 2]()  <!-- 3 spaces -->
      - [Heading 3]()  <!-- 6 spaces -->
   - [Heading 2]()  <!-- 3 spaces -->
<!--toc:end-->

marksman always uses two spaces for indentation. The relevant line from Marksman/Toc.fs:

https://github.com/artempyanykh/marksman/blob/a511779d2d2ad8c3fdf060d62d4dfb723ed23e2b/Marksman/Toc.fs#L31

tukusejssirs avatar Sep 28 '22 10:09 tukusejssirs

Thanks for raising this @tukusejssirs! Adding support for both would be helpful!

  • indentation config in .marksman.toml and
  • .editorconfig

artempyanykh avatar Oct 02 '22 18:10 artempyanykh