Skip to content

feat: add listIndentKind config option#176

Open
jamestrousdale wants to merge 1 commit into
dprint:mainfrom
jamestrousdale:feat/list-indent-kind
Open

feat: add listIndentKind config option#176
jamestrousdale wants to merge 1 commit into
dprint:mainfrom
jamestrousdale:feat/list-indent-kind

Conversation

@jamestrousdale
Copy link
Copy Markdown

Summary

  • Adds a new listIndentKind configuration option controlling how nested list items are indented
  • commonMark (default) keeps the existing behaviour — indent width matches the content column after the marker (3 for 1. , 4 for 10. , etc.)
  • pythonMarkdown enforces a minimum 4-space indent regardless of marker width, which is what tools like mkdocs-material need

Details

The indent for nested list items was previously hardcoded to marker_width + 1 (see gen_list in generate.rs). That's correct per CommonMark but breaks mkdocs-material's card grids and other features that depend on Python-Markdown's fixed 4-space rule.

The new option branches on the config at that single calculation point — no other logic changes. Default is commonMark so this is fully backwards-compatible.

Test plan

  • Existing list specs all pass unchanged (they run with the default commonMark)
  • New spec file Lists_ListIndentKind_PythonMarkdown.txt covers ordered, unordered, and double-digit marker cases with pythonMarkdown mode
  • cargo test green

Closes #147

New option to control how nested list items are indented:

- commonMark (default) — indents to align with content after the marker,
  so 3 spaces for "1. ", 4 for "10. " etc. No change in behaviour for
  existing users.
- pythonMarkdown — always uses at least 4 spaces of indent regardless of
  marker width. Needed for compatibility with tools like mkdocs-material
  which rely on Python-Markdown's 4-space list rule.

Closes dprint#147
@jamestrousdale
Copy link
Copy Markdown
Author

Hi @dsherret - do you have any comment on this PR? Anything I could add?

@i-yordanov-playalong
Copy link
Copy Markdown

Any updates?

This is going to make the plugin usable with mkdocs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

option to configure list indentation

2 participants