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

Ignore front-matter flag/config #154

Open
titpetric opened this issue Mar 22, 2024 · 4 comments
Open

Ignore front-matter flag/config #154

titpetric opened this issue Mar 22, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@titpetric
Copy link

I'd like to use mdox to reformat markdown documents (hugo), but not touch the front-matter. Currently the front-matter gets reordered and reindented, rather than being kept as is.

@bwplotka
Copy link
Owner

bwplotka commented Jul 3, 2024

👍🏽 help wanted!

@bwplotka bwplotka added the help wanted Extra attention is needed label Jul 3, 2024
@titpetric
Copy link
Author

@bwplotka this is a persistent pain in my butt and i'd like to contribute a PR for it;

the few issues arising from this are:

  • front-matter resorting
  • front-matter reindenting

Asume we can add --skip-front-matter, there is the question if configuring resorting and indenting would make sense. In that case, there would be multiple options to configure (skip front matter sort, skip front matter reindent, set front matter reindent to tab/space, set front-matter reindent size).

The latter options could be derived from .editorconfig but it requires adding support for it in mdox, right? The flags that are interesting there are indent_size, indent_style, and suppose some matching to find *.md or fall back to *. The whole app has few settings, so I am motivated to add as little flags as absolutely necessary, which in this case is some format of --skip.<step> under mdox fmt and .editorconfig support.

I'd like your input here, mainly around the flags to support this, or if .editorconfig support is desired.

@bwplotka
Copy link
Owner

Skipping does not sounds too bad. Never seen editor config convention, not sure how popular it is, but long term we might want a separate config file or so.

Curious what's wrong with front matter reorder/formatting? Maybe it's better to ensure there are options you would be happy with e.g. indent size or so?

Another idea would be to check the current indentation for the first item in the yaml and persist that? Less config options= better

@titpetric
Copy link
Author

Front-matter reordering would require review, and we'd like to keep that on markdown-side only. Also asuming from a dataset of about a 1000 pages, not all input is trustworthy so we can't just mdox fmt and be done with it. Suppose it's an issue from a git history perspective as well as the blame on the metadata would change by reordering, etc.

Editorconfig does present a challenge; yes, someone can add *.md settings, but this is technically *.yaml; While I'm happy it's an open standard and has quite a bit of adoption, it was just in avoidance of having fine grained skip flags.

can we go with --skip-front-matter, or just --soft-matter (default to true?). If there's a preferred naming option for the skip flag under mdox fmt, I'd like to take that and go with it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants