-
Notifications
You must be signed in to change notification settings - Fork 46
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
Configureable markdown formatting #331
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
Thanks for the issue! Here's my thoughts on adding configuration to mdformat. The docs also discuss this briefly.
If what you mean is literally Blackening Python codeblocks within a Markdown document, then that is a thing that already exists: https://github.com/hukkin/mdformat-black Also see other plugins https://mdformat.readthedocs.io/en/stable/users/plugins.html |
While I'm not a huge fan of introducing numerous config knobs, I have recently considered having two modes:
I haven't committed to actually accepting or implementing this but it's something I've though of. |
Thanks for your replies :) Indeed the motivation behind a configuration is that I would like "pretty" markdown files, pretty as in: markdown structured in a way that emphasizes the different structures so that they are recognizeable as markdown, with syntax highlighting only. Being simple and readable is one of the key-advantages of markdown. If I'll write:
That heading doesn't stand out enough. With a preceeding newline, it does. The comparison to black should underline the importance that such a tool would have for me personally and the status it could have in general <3 But have you considered doing this in a config-oriented way? This, and some "sensible defaults" could mean to be at least compliant with the commonmark-spec, but it could also mean to produce output that is compliant and "pretty". Have you thought about a I know about the plugins and they are not only the right way to implement this but also didacticly valueable. If someone asks me how they should write their plugin system, I would point them to mdformat. |
To clarify: Black also very much strives for no or low configurability. The flags you point to are for including and excluding files/filenamse, not syntax or style features.
Yeah this sounds a lot like what I named
Very happy to hear this! And yeah, it's worth noting that even if I reject everything proposed here and we make zero changes to mdformat, it is possible to implement everything discussed here so far simply by creating plugins such as
The |
Ah sorry, you are right, seems I didn't read the manual well enough. I had stuff like pylint in mind where you can include/exclude linting rules. Perhaps I'll share some thought about this: Python is syntactically more restricted what it even allows to format, so I would say there are less points left to discuss how one should format the stuff that allows change. In contrast, and definitly before commonmark, markdown was pretty "diverse" and ambiguous, so there are different "ways" people are still used to today. It is not necessary to accomodate all these different styles, and you already said that configurabilty (neither for mdformat nor the renderer) isn't a goal. It would be convenient for me, but that is not important. But in order to have less difference that would have to be accommodated (by configurability), and in order for mdformat to have a similar role to black (because it works for many people in a useful way), the important question is how markdown is used. That's why I found it so interesting that you are leaning more towards a minimal, diffable style. The main point I would like to make is that markdown is a format with the intend to be read and written by humans, and the markdown markup reflects the function of the different syntactical elements. It works as a lightweight markup language, and it works in a typographical sense without changing the format. And that should be reflected in the (or at least one) formatting style. Otherwise it would be severly limiting that
And about the way to do this:
Which I would be perfectly happy with :) |
I finally finished mdformat-mkdocs that formats list indents to 4-spaces and might help resolve the list-indent issue on bitbucket and the initial request While this plugin doesn't support extra new lines before the header, you can use my plugin as an example on modifying the |
Context
I prefer my documents to look like this:
So I'd like to have:
This is not exhaustive, it's just an example for how I would like my documents to look like.
Edit: We could check/warn if the chosen settings are not compliant with commonmark. I added
·
for spaces.Proposal
A solution would be to provide settings/options to make the style more configureable.
Or to have the ability to add a custom style.
This could also be solved if a markdown renderer would be a selectable renderer in executeablebooks/markdown-it-py, after all that issue brought me here, and it is still open.
Related to that, many older issues for markdown-it-py are about renderers (how do I add my own, plaintext renderer, …). Markdown rendering seems like a complicated problem for everyone. Maybe this could be solved by adding a mapping to panflute, as it was mentioned in another issue?
Sorry, if this proposal is kind of vague, but it seems that the issue spans multiple projects.
Tasks and updates
black
for markdown filesThe text was updated successfully, but these errors were encountered: