Indent setting to work with `mdformat-mkdocs`
In my current pre-commit file, I'm running mdformat twice, once with toc and once with mkdocs so that the lists generated have 4-space indents to comply with the mkdocs norm.
Current pre-commit
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
name: Format Markdown
entry: mdformat # Executable to run, with fixed options
language: python
types: [markdown]
args: [--wrap, "80", --number]
additional_dependencies:
- mdformat-toc
# run twice so that the TOC is updated to 4-indent
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
name: Format Markdown
entry: mdformat # Executable to run, with fixed options
language: python
types: [markdown]
args: [--wrap, "80", --number]
additional_dependencies:
- mdformat-mkdocs
Is it possible to add --indent X to Opts? Would the maintenance team be interested in a PR?
Hey, thanks for the issue!
I think better than configuration would be for mdformat-toc to detect the presence of mdformat-mkdocs (or vice versa) and change indentation accordingly.
Not sure, but maybe mdformat-mkdocs is a more natural place for this, as then all 4 space indent code is in one location? What does @KyleKing think? Would a PR be welcome?
I think a fairly simple POSTPROCESSOR function for "html_block" syntax, that doubles indent width if the "html_block" rendering starts with <!-- mdformat-toc start (and mdformat_toc.plugin is in RenderContext.options["parser_extension"] should suffice.
If Kyle doesn't want this, then I'll accept a PR here.
I agree that mdformat-mkdocs is probably the right place for any mkdocs-specific implementations
I’m happy to accept PRs and answer questions as well!
Hi, was having a look at this and willing to pick this up. I don't agree however that this belongs in mdformat-mkdocs but rather that this is a more specific problem with hardcoded rendering of markdown in this repo.
I believe, since this repo is the one adding markdown, it should generate said markdown with mdformat itself using whatever plugins are installed. As of right now, markdown is constructed like so:
https://github.com/hukkin/mdformat-toc/blob/027dc4048d01f8cca92514c5bf8fa5a210a9493b/mdformat_toc/plugin.py#L134-L137
Here the indentation is an issue, but what if some plugin decides to make * the bullet marker instead of -? That would break in a similar way. formatting the generated markdown using mdformat itself seems more robust to me. Let me know what you think.