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

Semantic line feeds issue in nested bullets in numbered lists #7

Closed
jamesbraza opened this issue Jul 17, 2023 · 9 comments · Fixed by #8
Closed

Semantic line feeds issue in nested bullets in numbered lists #7

jamesbraza opened this issue Jul 17, 2023 · 9 comments · Fixed by #8

Comments

@jamesbraza
Copy link

Same issue as #4, but for nested bullets inside a list.

  1. Line
    semantic line 1 (3 spaces deep)
    • Bullet (4 spaces deep)
      semantic line 2 (6 spaces deep)

I believe mdformat-mkdocs==1.0.2 is impacting the second semantic line feed.


I have prettier (.prettierrc.toml: tabWidth = 4) and mdformat, together in pre-commit:

    - repo: https://github.com/pre-commit/mirrors-prettier
      rev: v3.0.0
      hooks:
          - id: prettier
    - repo: https://github.com/executablebooks/mdformat
      rev: 0.7.16
      hooks:
          - id: mdformat
            additional_dependencies:
                - mdformat-black
                - mdformat-footnote
                - mdformat-frontmatter
                - mdformat-gfm
                - mdformat-mkdocs>=1.0.2rc2
            args: [--align-semantic-breaks-in-numbered-lists]
KyleKing added a commit that referenced this issue Jul 17, 2023
Add tests based on #6 and #7
@KyleKing
Copy link
Owner

I think this is fixed by: #8

Right now the changes only support semantic indents on bulleted items within a numbered list (i.e. numbered-bullet), but not when the numbered list is within a bulleted list (i.e. bullet-number-bullet). Does the latter also need to be supported? It adds a bit of extra complexity

@jamesbraza
Copy link
Author

jamesbraza commented Jul 18, 2023

I think ultimately the right solution is supporting recursive permutations of any combination of bullets and numbered lists, though I think it's okay to not support infinite recursions for now

One other case I just hit: simple bulleted lists. Can you add a case for that?

  • Line
    semantic line

@KyleKing
Copy link
Owner

Ah, I didn't think bulleted lists were handled correctly in mkdocs with a semantic indent which is why the feature was limited to numbered lists

Instead, it looks like they work fine and I generalized the logic in the PR. The important notes are:

  1. The CLI argument will now be --align-semantic-breaks-in-lists instead of --align-semantic-breaks-in-numbered-lists

  2. All lines are indented to the same semantic indent. Is this desired or should it be multiples of four when there is a new line? Example:

    1. Line
       semantic indent
    
       *Should this line be indented with 3 or 4 spaces?*

@KyleKing KyleKing reopened this Jul 18, 2023
@KyleKing
Copy link
Owner

I released v1.0.3 while pending input on the above questions: #7 (comment)

Let me know if v1.0.3 and the new CLI arg work as expected

@jamesbraza
Copy link
Author

  1. All lines are indented to the same semantic indent. Is this desired or should it be multiples of four when there is a new line? Example:
    1. Line
       semantic indent
    
       *Should this line be indented with 3 or 4 spaces?*
    

I think the asterisk line should be indented with 3 spaces for vanilla Markdown. You will want to confirm this with Mkdocs-style Markdown as well.

Also, thank you for the quick turnaround, it's awesome!

@KyleKing
Copy link
Owner

You're welcome; I'm happy to see my projects getting use!

@KyleKing
Copy link
Owner

KyleKing commented Jul 23, 2023

After some testing, mkdocs expects 4-space indents, which means that valid semantic-indented mkdocs markdown looks like this:

1. Line
   semantic indent (3 spaces)

    *Any lines separate by a new line*  (4 spaces)

Example of pending changes: https://github.com/KyleKing/mdformat-mkdocs/pull/10/files#diff-f21280fed25185b9d724c03bd5cf1397004cc3f24a6537f77d023e35b4655576


I released a preview version (1.0.4rc1) if you want to experiment with these changes: https://pypi.org/project/mdformat_mkdocs/1.0.4rc1/

@jamesbraza
Copy link
Author

Seems like a step forward with a more general arg name, thanks!

Now if only prettier would be as responsive as you (prettier/prettier#5019), I could un-ignore all my Markdown files and use this tool so they all coexist.

@KyleKing
Copy link
Owner

KyleKing commented Aug 4, 2023

I've released v1.0.4! Let me know if you run into any additional edge cases

@KyleKing KyleKing closed this as completed Aug 4, 2023
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