feat: support custom indent sublists BM-1120 #3371
Merged
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.
This PR is a sibling of this PR in the basemaps-mkdocs repository.
Problem
When formatting markdown (
.md
) files in Visual Studio Code, sublists are lost due to LINZ's formatting rules around how many spaces prescribe a tab.Currently, MkDocs requires sublist items to be indented 4 spaces relative to the parent. Like so:
However, LINZ's Prettier formatting rules (.prettierrc.cjs) trims such occurrences down to 2 spaces:
After the formatting, MkDocs interprets the
Child
sublist item as a member of the parent list. Effectively, the sublist is lost.Solution
I have identified a markdown extension called mdx_truly_sane_lists, which can solve the problem. The extension allows us to override the number of spaces required for MkDocs to preserve a sublist item from 4 spaces to 2 spaces, inline with LINZ's Prettier formatting rules.
Modifications
Sibling pull request
Dockerfile
Added an install command for the
mdx_truly_sane_lists
markdown extension.Updated the MkDocs base image to the latest version (9.5.44).
This pull request
MkDocs configuration (mkdocs.yml)
Verification
Building the Docker image
I used the following command to build a Docker image with which I could test my modifications:
Serving MkDocs locally
I then used the following command to serve MkDocs locally using the Docker image:
Testing sublist indent
For the given markdown snippet:
MkDocs correctly preserves the sublist items! 🎉