Commit bc334d4
authored
This PR is a sibling of [this PR][pr] in the **basemaps-mkdocs**
repository.
[pr]: linz/basemaps-mkdocs#8
---
### 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:
```md
- Parent
- Child
```
- However, LINZ's Prettier formatting rules
([.prettierrc.cjs][prettier]) trims such occurrences down to 2 spaces:
```md
- 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][mdx], 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][pr]
- #### 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](mkdocs)).
> Not required for the extension to work, just a convenient time to
update the image.
- #### This pull request
- #### MkDocs configuration ([mkdocs.yml][yml])
- Updated the [mkdocs.yml][yml] file of the [linz/basemaps][basemaps]
repo so that MkDocs uses the extension.
### Verification
- #### Building the Docker image
I used the following command to build a Docker image with which I could
test my modifications:
```bash
# 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:
```bash
# 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][snippet]:
```md
- 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 |
| - | - |
| ![][before] | ![][after] |
[jira]: https://toitutewhenua.atlassian.net/browse/BM-1120
[prettier]:
https://github.com/linz/style-js/blob/437f754e17eca905a880606219c832e8fc9d5f9c/.prettierrc.cjs
[mdx]: https://github.com/radude/mdx_truly_sane_lists
[mkdocs]:
https://github.com/squidfunk/mkdocs-material/pkgs/container/mkdocs-material/300822759?tag=9.5.44
[yml]:
https://github.com/linz/basemaps/blob/385971dc23c0b1cd9c354c5028d47d01ab5ae584/mkdocs.yml
[basemaps]: https://github.com/linz/basemaps
[snippet]:
https://github.com/linz/basemaps/blob/385971dc23c0b1cd9c354c5028d47d01ab5ae584/docs/developer-guide/run-basemaps-locally.md
[before]:
https://github.com/user-attachments/assets/0ddbbbaa-9b1a-49df-bf54-74c2d7357d0d
[after]:
https://github.com/user-attachments/assets/301f7ca5-80e5-4bf9-97c2-4841a0bec68b
1 parent ae07a95 commit bc334d4
2 files changed
+10
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
| |||
0 commit comments