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

Consider adding support for GFM, footnote and frontmatter syntax to default installation #332

Open
hukkin opened this issue Jun 28, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@hukkin
Copy link
Owner

hukkin commented Jun 28, 2022

Context

It seems many users do not have a good understanding of what CommonMark is, and that the Markdown they use (often in GitHub) supports additional syntax such as all the GFM extensions, footnotes and frontmatter. This leads to frustration: people think that mdformat is broken if it breaks their frontmatter syntax, even though it is clearly documented that only CommonMark is supported and the fix is easy -- install a plugin that adds support for the additional syntax.

Proposal

Make pip install mdformat support GFM, footnote and frontmatter syntax in addition to CommonMark.
Make pip install mdformat-core (or maybe mdformat-commonmark is better?) install what pip install mdformat currently does.

This means that the current package is moved under mdformat-core. Then we make the mdformat package essentially an empty package that depends on mdformat-core, mdformat-gfm, mdformat-footnote and mdformat-frontmatter.

Tasks and updates

No response

@hukkin hukkin added the enhancement New feature or request label Jun 28, 2022
@inktrap
Copy link

inktrap commented Jun 29, 2022

What if the user had to specify the dialect/flavor of markdown? Then an error message could remind them that the package is not installed.

  • something like black's -t, --target-version, but --target-format doesn't really fit?!
  • pandoc's -f --from or -t --to or --read --write?
  • -f, --format ? would be good because of --from, but typically -f stands for file.

If one works on two unrelated projects it is imagineable that they chose to use different markdown dialects that are incompatible to one-another.

It is great to reduce the confusion of users, so there are less issues and more adaption. If I had to guess, GFM is probably most-widely used and so it is no surprise that markdown-it-py chose these presets as well. But I just want to mention that GitHub is a commercial microsoft-owned platform and personally I wouldn't want to give them an advantage over other dialects, f.e. Gitlab or Pandoc. Yes, I know, this is an issue on GitHub.

Edit: markdown-it uses GFM as a preset, markdown-it-py uses commonmark and supports gfm-like.

FYI: Rendering can be compared here and here is some overview as a table.

It would be more consistent with markdown-it-py though, which would be really awesome!

@inktrap
Copy link

inktrap commented Jun 29, 2022

And if you are going to change the structure of packages … what about those that contain an underscore?

│ 📂 mdformat_deflist     │ 0.1.1   │ 21-06-2021 │ An mdformat plugin for markdown-it-deflist.                                  │
│ 📂 mdformat_openmmlab   │ 0.0.1   │ 27-05-2022 │ An mdformat plugin for...                                                    │
│ 📂 mdformat_tables      │ 0.4.1   │ 04-05-2021 │ An mdformat plugin for rendering tables.                                     │
│ 📂 mdformat_frontmatter │ 0.4.1   │ 09-06-2021 │ An mdformat plugin for parsing / ignoring frontmatter.                       │
│ 📂 mdformat_footnote    │ 0.1.1   │ 16-02-2022 │ An mdformat plugin for parsing/validating footnotes                          │
│ 📂 mdformat_myst        │ 0.1.5   │ 02-02-2022 │ Mdformat plugin for MyST compatibility.                                      │
│ 📂 mdformat_pelican     │ 0.1.0   │ 29-08-2021 │ An mdformat plugin for pelican markdown items                                │

@rpdelaney
Copy link
Contributor

rpdelaney commented Oct 14, 2022

As a user, I don't consider this an annoyance rooted in mdformat. It's a standard cost of doing business with open standards: "open" means "everyone has their own flavor". I use mdformat because I don't have time or interest to get deep into what is CommonMark and what isn't, and it makes my life much easier.

If you merge these plugins into the trunk, you may end up maintaining them as well. If you are concerned about that, I think it would be enough to detect non-compliant markdown and print a warning suggesting the use of a plugin: then you don't have to close github issues about unexpected behavior with markdown that doesn't conform to the CommonMark spec. :)

@inktrap
Copy link

inktrap commented Oct 15, 2022 via email

@rpdelaney
Copy link
Contributor

@inktrap I agree with much of what you said, for what that's worth. I really only mean to float this as an alternative solution.

@csala
Copy link

csala commented Jan 6, 2023

I just 👎 'ed the initial proposal as a form of downvoting.

Personally, I think that the current structure of mdformat supporting the smallest spec set and letting plugins add to it is much better than having it the other way around. This is especially relevant, considering that mdformat is already out there and plugins exist which depend on it.

If a specific preset that is equivalent to the current mdformat with a few plugins is wanted, I would suggest to rather create a new package for that, like mdformat-extended or mdformat-default-plugins, something that implies that it is a superset of what plain mdfromat is.

If one works on two unrelated projects it is imagineable that they chose to use different markdown dialects that are incompatible to one-another.

@inktrap I suppose this is assuming that one uses the same mdformat installation for both projects, which is definitely not what environment isolation tools like pre-commit encourage. I would say that if someone works on two different projects, they should be encouraged to run mdformat from 2 different installation stacks (like 2 different pre-commit configs), with potentially different plugin sets.

@csala
Copy link

csala commented Jan 9, 2023

Here is an interesting approach from the mdformat-mkdocs plugin:

Tip: this package has a pip extra, recommended, of plugins that work well with mkdocs:

  • mdformat-admon
  • mdformat-beautysh
  • mdformat-black
  • ...

This could be an option here too: Have mdformat[recommended] or mdformat[featured_plugins]

@inktrap
Copy link

inktrap commented Jan 9, 2023 via email

@KyleKing
Copy link
Contributor

KyleKing commented Oct 30, 2024

Unless plugin authors have the capability to disable plugins, I think bundling plugins by default will cause conflicts.

I agree that providing an "extra" would be a good middle ground (maybe 'github-markdown', 'github', or github-markdown-plugins?). New users can then try out mdformat with just:

pipx install 'mdformat[github-markdown]'
mdformat README.md

Or, even when adding additional plugin for uv, having the extra simplifies the command: uvx --with='mdformat[github-markdown]' --with=mdformat-gfm-alerts mdformat README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants