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

Nested List and Inline markdown issues #1500

Open
Lizhenghe-Chen opened this issue Dec 26, 2024 · 3 comments
Open

Nested List and Inline markdown issues #1500

Lizhenghe-Chen opened this issue Dec 26, 2024 · 3 comments

Comments

@Lizhenghe-Chen
Copy link

I have found that some inline lists and bold fonts are not represented correctly in mkdocs material, but are displayed correctly in the traditional Markdown compiler.
A markdown of the form shown here will display the correct hierarchy and bolding correctly in both material and traditional markdown compilers:

  • Nulla et rhoncus turpis. Mauris ultricies elementum leo. Duis efficitur
    accumsan nibh eu mattis. Vivamus tempus velit eros, porttitor placerat nibh
    lacinia sed. Aenean in finibus diam Test.

    • Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
    • Nam vulputate tincidunt fringilla.
    • Nullam dignissim ultrices urna non auctor.
      image
      image

However, when I remove some redundant-looking spaces (which is what most markdown editor plugins usually do), the traditional compiler displays it correctly, but material no longer displays the correct list hierarchy and bolding:

  • Nulla et rhoncus turpis. Mauris ultricies elementum leo. Duis efficitur
    accumsan nibh eu mattis. Vivamus tempus velit eros, porttitor placerat nibh
    lacinia sed. Aenean in finibus diamTest.

    • Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
    • Nam vulputate tincidunt fringilla.
    • Nullam dignissim ultrices urna non auctor.
      image
      image

The Issue was from : squidfunk/mkdocs-material#7841 (comment)

@facelessuser
Copy link
Collaborator

There are a couple of things here.

  1. I'm not sure what we mean by "traditional Markdown compilers", so let's ignore that. Python Markdown has been around a very long time, before recent CommonMark parsers and was based on the original spec that was outlined in https://daringfireball.net/projects/markdown/.

  2. I'm not sure what extensions or options you are configuring when displaying your Markdown results. That is a must when we are talking about behavior. So, I am going to assume no additional extensions and no special options when talking about the behavior until at some future time when you disclose what options you are using.

Anyways, so you are pointing out two things that are clearly documented in Python Markdown's documentation.

  1. List indentation is clearly documented as requiring 4 spaces or one tab (tabs being translated to 4 spaces, though you can represent a tab at any length in your editor). This is documented here and describes ways in which you can configure the accepted length with the associated caveats mentioned.

  2. Middle-word emphasis is also described here and generally relates to emphasis with _, * will perform middle-word emphasis using the default configuration. I'm not sure what your configuration looks like so I cannot speculate, but you can see below that middle-word emphasis works fine.

"""Example."""
import markdown

print(f'Markdown Version: {markdown.__version__}')
print('-----')

MD = """
diam**Test**

diam **Test**
"""

extensions = []
extension_configs = {}

print(markdown.markdown(MD, extensions=extensions, extension_configs=extension_configs))
<p>diam<strong>Test</strong></p>
<p>diam <strong>Test</strong></p>

If you have something specific you'd like to demonstrate, please create a minimal, reproducible example. You can use the script above as a template if it is easier.

@Lizhenghe-Chen
Copy link
Author

I'm sorry to have caused you confusion. Since I was using markdown rendering in both Github and VsCode with only two spaces for sublists, in addition middleWorld, e.g. bolding is rendered without additional spaces, I found these differences when using MkDocs, if these formats above are Python Markdown specifications, that Indeed not an issue.

It just bothers me that when I build my MKDocs site using GitHub as well as the regular markdown editing style (which uses only two spaces, and compiles the middle word without spaces), they don't display correctly. The following two writing formats, the first using the Python Markdown specification and the second the regular writing style, make no difference in the GitHub page and VSCode, but not in MakeDocs. You can see the link to the first time I asked the question, where the MakeDocs material points to Python Markdown as the issue:squidfunk/mkdocs-material#7841 (comment).

- Nulla et rhoncus turpis. Mauris ultricies elementum leo. Duis efficitur
  accumsan nibh eu mattis. Vivamus tempus velit eros, porttitor placerat nibh
  lacinia sed. Aenean in finibus diam **Test**.

    * Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
    * Nam vulputate tincidunt fringilla.
    * Nullam dignissim ultrices urna non auctor.
- Nulla et rhoncus turpis. Mauris ultricies elementum leo. Duis efficitur
  accumsan nibh eu mattis. Vivamus tempus velit eros, porttitor placerat nibh
  lacinia sed. Aenean in finibus diam**Test**.

  * Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
  * Nam vulputate tincidunt fringilla.
  * Nullam dignissim ultrices urna non auctor.

@facelessuser
Copy link
Collaborator

It just bothers me that when I build my MKDocs site using GitHub as well as the regular markdown editing style (which uses only two spaces, and compiles the middle word without spaces), they don't display correctly.

  1. Let me be very clear. I cannot reproduce your middle-word problem with the example you have given, which means something else is causing that issue for you, so you would need to give us a minimal, reproducible example showing us the specific Markdown extension (with configuration) that is causing the issue. If you do not provide that, I cannot help further on that issue.

  2. As for the list problem, you are welcome to use 4 spaces in both GitHub and Python Markdown which will work in both. You can search our issues and see that the 2 space difference has been brought up multiple times. This difference is documented and the repo owner has been very clear that there are no intentions to change this.

    So, you can either use 4 spaces, configure tab_length as described in the docs (accepting any issues that it may or may not cause, though I don't think MkDocs exposes changing this option), or write your own list extension (or use one if it already exists) that uses 2 spaces for lists. The wiki points to a lot of third-party extensions, I believe one of them (though I don't recall which) allows for 2 space indents with lists, though I cannot speak to whether it introduces other issues as I do not use it.

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

No branches or pull requests

2 participants