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

[Feature Request] Support git diff code blocks #36

Open
elliotweiser opened this issue Mar 18, 2024 · 3 comments
Open

[Feature Request] Support git diff code blocks #36

elliotweiser opened this issue Mar 18, 2024 · 3 comments

Comments

@elliotweiser
Copy link

Currently, git-diff style code blocks do not appear to be supported/respected by the formatter, particularly when describing a list of deletions. As a result, a GitHub workflow snippet appears to be treated as YAML rather than a git diff. As a result...

This content:

- build_args: |
-   "my_host=${{ vars.MY_HOST }}"
- secrets:
-   "my_token=${{ secrets.MY_TOKEN }}"
-   "my_user=${{ vars.MY_USER }}"
-   "my_host=${{ vars.MY_HOST }}"

Is formatted to this:

- build_args: |
- "my_host=${{ vars.MY_HOST }}"
- secrets:
- "my_token=${{ secrets.MY_TOKEN }}"
- "my_user=${{ vars.MY_USER }}"
- "my_host=${{ vars.MY_HOST }}"

At a glance, this is just whitespace, but important information gets lost about the structure of the described source file. It would be great to see this use-case supported.

It's certainly possible that I'm doing something wrong.

@KyleKing
Copy link
Collaborator

KyleKing commented Mar 18, 2024

Hi, thanks for trying out mdformat-gfm!

Locally, I ran the latest version of mdformat with the below markdown file and the plugin didn't modify the formatting within the code block.

```diff
- build_args: |
-   "my_host=${{ vars.MY_HOST }}"
- secrets:
-   "my_token=${{ secrets.MY_TOKEN }}"
-   "my_user=${{ vars.MY_USER }}"
-   "my_host=${{ vars.MY_HOST }}"
```

Steps:

pipx install mdformat
pipx inject mdformat mdformat-gfm
mdformat ./tmp.md

Do you have another mdformat plugin installed? mdformat-gfm doesn't modify any text within backticks, but there are a number of other plugins which could be removing the whitespace

@elliotweiser
Copy link
Author

Do you have another mdformat plugin installed? mdformat-gfm doesn't modify any text within backticks, but there are a number of other plugins which could be removing the whitespace

Very possible. I'll dig deeper and see what comes up. There's quite a bit going on in terms of formatting, and I believe we're have at least a few plugins to mdformat at play. Thanks for the sanity-check and repro steps-- I'll give this a shot just to be sure.

@KyleKing
Copy link
Collaborator

@elliotweiser, did you find out what plugin was the problem?

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

No branches or pull requests

2 participants