Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support custom indent sublists BM-1120 #3371

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

tawera-manaena
Copy link
Contributor

@tawera-manaena tawera-manaena commented Nov 12, 2024

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:

    - Parent
        - Child
  • However, LINZ's Prettier formatting rules (.prettierrc.cjs) trims such occurrences down to 2 spaces:

    - Parent
      - Child

    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).

        Not required for the extension to work, just a convenient time to update the image.

  • This pull request

Verification

  • Building the Docker image

    I used the following command to build a Docker image with which I could test my modifications:

    # from the root of the `basemaps-mkdocs` repo
    docker build --tag basemaps-mkdocs-test .
  • Serving MkDocs locally

    I then used the following command to serve MkDocs locally using the Docker image:

    # from the root of the `basemaps` repo
    docker run --rm -v $PWD:/docs -p 8000:8000 basemaps-mkdocs-test serve -a 0.0.0.0:8000
  • Testing sublist indent

    For the given markdown snippet:

    - build the **basemaps** packages
    - configure and run the **basemaps/server** package:
      - using LINZ's imagery
      - using your own imagery

    MkDocs correctly preserves the sublist items! 🎉

    Before After

@Wentao-Kuang
Copy link
Contributor

The build-doc deployment seems broken in CI/CD

@tawera-manaena
Copy link
Contributor Author

tawera-manaena commented Nov 12, 2024

The build-doc deployment seems broken in CI/CD

I anticipate that at the moment. The sibling PR will need to be approved first as it updates the basemaps-mkdocs image as required for this PR to pass the checks. Happy to explain any concerns.

Update

The sibling PR has been approved and merged into the basemaps-mkdocs master branch with a new release. The previously failing check now succeeds. 🎉

@tawera-manaena tawera-manaena marked this pull request as ready for review November 14, 2024 02:43
@tawera-manaena tawera-manaena requested a review from a team as a code owner November 14, 2024 02:43
@tawera-manaena tawera-manaena added this pull request to the merge queue Nov 14, 2024
Merged via the queue into master with commit bc334d4 Nov 14, 2024
12 checks passed
@tawera-manaena tawera-manaena deleted the fix/support-custom-indent-sublists branch November 14, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants