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

Unexpected removal of newlines #365

Closed
rpdelaney opened this issue Oct 13, 2022 · 2 comments
Closed

Unexpected removal of newlines #365

rpdelaney opened this issue Oct 13, 2022 · 2 comments
Labels
question Further information is requested

Comments

@rpdelaney
Copy link
Contributor

rpdelaney commented Oct 13, 2022

Describe the bug

context
We use markdown ADRs (mADR) to document engineering decisions. There is a template for an mADR.

We also use mdformat to format markdown files, which is enforced by pre-commit and in CI.

expectation
When running mdformat on the mADR template, I expected that the HTML rendering on github would not dramatically change.

bug
But instead, several lines were joined into a preceding header:

----
+______________________________________________________________________
+
 # These are optional elements. Feel free to remove any of them.
-status: {proposed | rejected | accepted | deprecated | … | superseded by [ADR-0005](0005-example.md)}
-date: {YYYY-MM-DD when the decision was last updated}
-deciders: {list everyone involved in the decision}
-consulted: {list everyone whose opinions are sought (typically subject-matter experts); and with whom there is a two-way communication}
-informed: {list everyone who is kept up-to-date on progress; and with whom there is a one-way communication}
----
+
+## status: {proposed | rejected | accepted | deprecated | … | superseded by [ADR-0005](0005-example.md)} date: {YYYY-MM-DD when the decision was last updated} deciders: {list everyone involved in the decision} consulted: {list everyone whose opinions are sought (typically subject-matter experts); and with whom there is a two-way communication} informed: {list everyone who is kept up-to-date on progress; and with whom there is a one-way communication}

problem
This is a problem for us because doing a recursive mdformat or pre-commit run --all with an mdformat hook will always fail unless we break the template to match mdformat's expected behavior.

Reproduce the bug

$ curl 'https://raw.githubusercontent.com/adr/madr/main/template/adr-template.md' > template.md
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3103  100  3103    0     0  40925      0 --:--:-- --:--:-- --:--:-- 43704
$ mdformat template.md

List your environment

$ python3 --version
Python 3.10.6
$ mdformat --version
mdformat 0.7.16 (mdformat_tables: 0.4.1, mdformat_gfm: 0.3.5, mdformat_toc: 0.3.0, mdformat_black: 0.1.1)

Relevant pre-commit config:

   - repo: https://github.com/executablebooks/mdformat
     rev: 0.7.16
     hooks:
       - id: mdformat
         additional_dependencies:
           - mdformat-gfm
           - mdformat-toc
@rpdelaney rpdelaney added the bug Something isn't working label Oct 13, 2022
@hukkin hukkin added question Further information is requested and removed bug Something isn't working labels Oct 14, 2022
@hukkin
Copy link
Owner

hukkin commented Oct 14, 2022

I expected that the HTML rendering on github would not dramatically change.

Quoting https://github.com/executablebooks/mdformat#installing

Note that GitHub's Markdown renderer supports syntax extensions not included in the GFM specification. For full GitHub support do:

   pip install mdformat-gfm mdformat-frontmatter mdformat-footnote

Mdformat is CommonMark compliant by default. You are using frontmatter syntax which isn't included in CommonMark or GFM so you'll need to install mdformat-frontmatter.

@hukkin hukkin closed this as completed Oct 14, 2022
@hukkin
Copy link
Owner

hukkin commented Oct 14, 2022

Cross-referencing #332

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

No branches or pull requests

2 participants