feat: add listIndentKind config option#176
Open
jamestrousdale wants to merge 1 commit into
Open
Conversation
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
Author
|
Hi @dsherret - do you have any comment on this PR? Anything I could add? |
|
Any updates? This is going to make the plugin usable with mkdocs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
listIndentKindconfiguration option controlling how nested list items are indentedcommonMark(default) keeps the existing behaviour — indent width matches the content column after the marker (3for1.,4for10., etc.)pythonMarkdownenforces a minimum 4-space indent regardless of marker width, which is what tools like mkdocs-material needDetails
The indent for nested list items was previously hardcoded to
marker_width + 1(seegen_listingenerate.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
commonMarkso this is fully backwards-compatible.Test plan
commonMark)Lists_ListIndentKind_PythonMarkdown.txtcovers ordered, unordered, and double-digit marker cases withpythonMarkdownmodecargo testgreenCloses #147