executablebooks / mdformat-myst

Mdformat plugin for MyST compatibility
MIT License
7 stars 2 forks source link

mdformat-myst adds unwanted space after a header target #20

Closed devmcp closed 2 years ago

devmcp commented 2 years ago

Describe the bug

Having installed mdformat-myst, when I run mdformat it changes

(my_header)=
### My Header

to

(my_header)=

### My Header

which I believe it shouldn't do

Reproduce the bug

See above

List your environment

mdformat-myst v0.1.5

welcome[bot] commented 2 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] commented 2 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

hukkin commented 2 years ago

Thanks for the issue!

Mdformat is consistent in that it separates all blocks with an empty line. Currently, the MyST target syntax is not an exception to this rule. If you have a good reason why this should be special cased (and under what circumstances) would be nice to hear it, but at least I'm happy with the current state.

devmcp commented 2 years ago

As a label for the heading, I guess it just seems like it belongs with it rather than in a separate section. To me, with the space, it looks like it's part of the content of the previous section. I don't know of any other instances like this so I think it would just be a single specific exception for the case of target headers.

hukkin commented 2 years ago

Even if you mean the target to be point to the heading, how would mdformat know that is the case?

AFAIK, a target preceding a heading doesn't really point to the heading (or any other element for that matter), but rather the location in the document (in your case immediately before the heading). I may be wrong here, but this is my understanding.

Targets can also be used in other locations where they don't immediately precede a heading. What newlines should we have if the target is located e.g. between two paragraphs?

devmcp commented 2 years ago

Ah. You're right. I misunderstood how targets are used. Thanks for taking the time to enlighten me! 😄