butler54 / mdformat-frontmatter

mdformat plugin to ensure frontmatter is respected.
MIT License
7 stars 3 forks source link

Can you avoid the `ruamel-yaml` dependency? #22

Open sanmai-NL opened 1 year ago

sanmai-NL commented 1 year ago

This dependency is highly idiosyncratic. It still uses setup.py and seems to generate one, indeed. It also generates source code within a Dockerfile. It uses custom C source code. The sole maintainer hosts its source code on SourceForge, an outdated platform. He categorizes these packages on PyPI as beta quality.

Can you not use the more popular PyYAML?

sanmai-NL commented 1 year ago

Regardless of the practices by its maintainer, ruamel-yaml is still functionally better than PyYAML.

sanmai-NL commented 1 year ago

Would it be possible to adopt https://github.com/eyeseast/python-frontmatter? This is more feature complete than the self-developed source code. You'd still transitively depend on ruamel-yaml, I surmise, but at least the choice of YAML library will no longer be your concern.

butler54 commented 1 year ago

Sorry for not getting back to you.. I'll have a look shortly

butler54 commented 1 year ago

My original issue with Pyyaml were some issues around ordering and duplicate keys. It's been 2-3 years since I had that issue (with a different project).

I think based on the requirements for #22 I'll need to do some testing.

butler54 commented 12 months ago

The fundamental challenge I have here is that we lose:

  1. Ordering of elements
  2. Changes behaviour from throwing an error on a duplicate key to stripping the duplicate key (actually the first key in a document gets overwritten by the first).

Effectively: the nature of the opinionation changes). I'd look for feedback as to whether that is something of interest.

sanmai-NL commented 12 months ago

@butler54 I assume you're referring to PyYAML, rather than python-frontmatter? From an outside point of view, adopting the latter seems the easiest migration path. And the matter of switching from ruamel-yaml to PyYAML can be considered within the scope of python-frontmatter.

butler54 commented 11 months ago

Unfortunately python-frontmatter's api today would not deliver consistent results due to behaviour differences in the yaml parses (e.g. pyyaml will enforce alphabetical ordering of keys when writing out which is inconsistent with current behaviour).

That said - the benefits of being able to support yaml/toml/json outweigh that change. Will most likely build it as a major release shorlty.