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

No generation if indentation is 2 spaces? #14

Closed
a4z opened this issue Dec 29, 2022 · 9 comments · Fixed by #15
Closed

No generation if indentation is 2 spaces? #14

a4z opened this issue Dec 29, 2022 · 9 comments · Fixed by #15

Comments

@a4z
Copy link

a4z commented Dec 29, 2022

Hi,

It seems I do not get the site map when the markdown file I use is indented 2 spaces.
Only 4 works. What is unfortunate since this conflicts with some auto-format rules I have.

Is there a way to make it work with 2 spaces?

like this

* [Home](index.md)
  * [About](about.md)

instead of

* [Home](index.md)
    * [About](about.md)

?

@a4z
Copy link
Author

a4z commented Dec 29, 2022

Additional info:
Markdownlint, expects 2 spaces
https://github.com/DavidAnson/markdownlint/blob/v0.26.2/doc/Rules.md#md007

@oprypin
Copy link
Owner

oprypin commented Dec 29, 2022

The original Markdown specification requires lists to be indented by 4 spaces. If there are fewer spaces, it is not counted as indentation.

So first off, I sure hope that this linter can be changed so it doesn't recommend broken Markdown instead of correct Markdown.

Example for markdownlint:
https://github.com/mkdocs/mkdocs/blob/56b235a8ad43f2300d17f87e6fa4de7a3d764397/.markdownlintrc#L14


MkDocs uses Python-Markdown which closely follows this original specification.

So, if you put such a list into a normal Markdown file within MkDocs, it will also be considered a flat list - not indented. So, you already have a problem with MkDocs regardless of this plugin. Just try it and see.


mkdocs-literate-nav doesn't parse Markdown, it uses exactly what MkDocs parsed.
So, if you solve the issue you're having with MkDocs overall, it will also solve the issue for this plugin.


To solve this for MkDocs overall, I believe this plugin will do the trick:
https://github.com/radude/mdx_truly_sane_lists

markdown_extensions:
  - mdx_truly_sane_lists

@oprypin oprypin closed this as completed Dec 29, 2022
@a4z
Copy link
Author

a4z commented Dec 29, 2022

lot of valuable information, thank you!

@a4z
Copy link
Author

a4z commented Dec 29, 2022

using mdx_truly_sane_lists and 2 spaces makes the navigation.md rendered correctly, but the navigation is still messed up.

there seems to be no real solution, except, to keep the indent on 4 spaces and add a linter config to enforce that

@oprypin
Copy link
Owner

oprypin commented Dec 29, 2022

Oh, sorry. So what I said is wrong 😞

mkdocs-literate-nav doesn't parse Markdown, it uses exactly what MkDocs parsed.
So, if you solve the issue you're having with MkDocs overall, it will also solve the issue for this plugin.

Instead, it just uses Python-Markdown without any extensions.

markdown.markdown(md, extensions=[ext])

I could do a change to actually make it work like I said, but not sure what's best.

@oprypin oprypin reopened this Dec 29, 2022
@a4z
Copy link
Author

a4z commented Dec 29, 2022

mdx_truly_sane_lists seems to be super nice and helpful. It fixes some docs I have imported, where no one will ever have the energy to reformat them.
It would be awesome if it could be used, also in the nav section and have a consistent style throughout the project

@oprypin
Copy link
Owner

oprypin commented Dec 29, 2022

Thanks for the productive discussion. I have opened a pull request that does this.
Likely to be released tomorrow.

I even discovered that Python-Markdown actually has configurable indentation, but it's impossible to specify it in MkDocs itself.

@a4z
Copy link
Author

a4z commented Dec 29, 2022

Thank you for following up on the topic and for the fast reaction! So great getting that feature in such a short time.

I even discovered that Python-Markdown actually has configurable indentation, but it's impossible to specify it in MkDocs itself.

Do you think this should be reported to mkdocs?

@oprypin
Copy link
Owner

oprypin commented Dec 29, 2022

Well I'm keeping track of this for mkdocs myself.
I think in the end it's actually not such a useful config in the general case because
https://github.com/Python-Markdown/markdown/blob/4dab9a7436357173fad08a0f4e67a63daaaa15a6/docs/index.md?plain=1#L93

this will affect indentation for all aspects of the syntax (including root level code blocks).

-doesn't seem like something I'd want to encourage

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 a pull request may close this issue.

2 participants