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

Make heading style formatting configurable #283

Open
2 tasks
arwedus opened this issue Nov 24, 2021 · 5 comments
Open
2 tasks

Make heading style formatting configurable #283

arwedus opened this issue Nov 24, 2021 · 5 comments
Labels
enhancement New feature or request plugin A plugin should be created or updated

Comments

@arwedus
Copy link

arwedus commented Nov 24, 2021

Description / Summary

In our (big) project, we have the convention to format at least level 1 headings always with Setext (underline) - there is also always just one level 1 heading per document allowed. We leave it up to individual subprojects whether they want to consistently apply setext style headings for level 2 as well or whether they want to start using ATX headings there.

I kindly request a configuration option "first_atx_heading_level". Allowed values: (1, 2, 3). Default value: 1

Effect: All headings of level below and including "first_atx_heading_level" are formatted with ATX style. All levels above are consistently formatted with setext (underline).

Value / benefit

This would actually enable us to use your great program!
We have made the choice for Setext because a single # character is visually very unimpressive. Setext does an inversion: The lower the heading is, the more it stands out in the code. A single # can also be confused with the start of a line comment in many scripting languages. Last but not least, we use MyST-parser and sphinx, mostly, and we want to keep a little visual consistency with the restructuredtext domain.

Implementation details

No response

Tasks to complete

  • Discuss and decide whether you accept this change in general.
  • Please give feedback whether you would be interested in implementing this yourself, or provide some hints for implementation.
@arwedus arwedus added the enhancement New feature or request label Nov 24, 2021
@hukkin
Copy link
Owner

hukkin commented Nov 24, 2021

Hey, thanks for the issue!

Firstly, a few things that I'll likely be repeating in every issue that asks for configuration 😄 : As a user and especially as a maintainer, I prefer an opinionated formatter with good defaults over a configurable formatter. The benefits are:

  • As a user: no need for pointless arguments over which configurable style is better. Ideally only one decision to make: whether to use the formatter or not?
  • As a maintainer: no need to maintain and test an endlessly growing matrix of configuration options. E.g. this change will slow down tests 3x, the next config knob will bump that up to 9x etc.

And yeah, there are a few config knobs already but I don't want any more unless for a very good reason.

I'll consider but please don't get your hopes up.

It should be fairly trivial to come up with something like a mdformat-setext plugin that does what you want. See the docs and some maybe some example plugin like mdformat-tables and feel free to ask questions about plugin development if you decide going down that road!

@hukkin hukkin added needs decision plugin A plugin should be created or updated labels Nov 24, 2021
@jamesquilty
Copy link

@arwedus my context is similar to yours and the inability to configure mdformat blocks its use and has created additional work.

@hukkin I have some incomplete local hacks to configure mdformat to conform to my context and some development help to complete this would be appreciated. I'd be happy to contribute a plugin which provides a general configuration feature if it's technically possible.

@jamesquilty
Copy link

This Issue motivated me to complete my hacking, which I've pushed to a branch on my fork: add-defaults-to-configuration.

@arwedus
Copy link
Author

arwedus commented Nov 28, 2021

@hukkin: I'm fine with a heading-formatter plug-in, but will most likely not have time to work on that this year.

I have some doubts about your argument that the number of tests required for n configuration options scales with n^2, though:

One could use the classification tree method after partitioning the configuration space in equivalence classes. I.e., in a test case that handles lists, or paragraphs, I do not have to test different configuration options for the heading as headings cannot appear in those blocks. One only needs to extend all tests that handle headings by an additional test for the output formatting. Not even the part that detects headings in the input needs to be covered by more tests than before.

@hukkin
Copy link
Owner

hukkin commented Feb 14, 2022

I think this should be implemented in a plugin.

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

No branches or pull requests

3 participants