Skip to content

Use mdformat for markdown formatting #4244

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

Merged
merged 10 commits into from
Apr 3, 2025
Merged

Conversation

jtraglia
Copy link
Member

@jtraglia jtraglia commented Apr 3, 2025

I was reviewing old PRs and saw this:

After reviewing mdformat I realized this is exactly what we've been looking for! It fixes these issues:

For this, I used the following extensions for GitHub flavored markdown and for table of contents:

The benefits of mdformat...

  1. It's so much faster than doctoc (1.2 seconds vs 10.7 seconds, ~9x faster).
  2. We don't need to install Node.js for an otherwise pure-python project.
  3. It catches formatting problems (eg the missing code block backticks in eip7732 specs).
  4. It automatically formats all of our tables.
  5. It uses consistent list item markers.
  6. It deletes trailing whitespace.
  7. It deletes unnecessary double spaces.
  8. And more...

I had to make one notable non-formatting change to get this to work:

  • Replace [0]: # (eth2spec: skip) with <!-- eth2spec: skip -->

The formatter was removing these footnotes because they unused, makes sense. My solution was to update this to use an HTML comment instead. The change in the pyspec generator was easy and arguably better than before.

@jtraglia jtraglia added the general:presentation Presentation (as opposed to content) label Apr 3, 2025
@jtraglia jtraglia merged commit d181573 into ethereum:dev Apr 3, 2025
19 of 37 checks passed
@jtraglia jtraglia deleted the mdformat branch April 3, 2025 14:37
jtraglia added a commit that referenced this pull request Apr 10, 2025
* Replace skip footnote with html block

* Remove unnecessary duration columns

* Add mdformat to pyproject

* Start to use mdformat-toc

* Remove table of contents headers

* Fix empty header

* Finally, run mdformat

* Remove doctoc from CI

* Fix issue with eip7732

* Error if linter changes something in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:presentation Presentation (as opposed to content)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants