Skip to content

CI: Validate headings #596

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

CI: Validate headings #596

wants to merge 7 commits into from

Conversation

ewels
Copy link
Member

@ewels ewels commented Apr 9, 2025

New script + GitHub actions workflow to validate any markdown files that have been edited in a PR. Checks:

  • Number has a trailing .
  • Markdown heading depth matches number (eg. ### 1.2. and not # 1.2.)
  • Numbers start at 0 or 1 for a given heading depth
  • Numbers are sequential

Can be run locally on all files, also has a --fix parameter to automagically fix the markdown in-place.

CleanShot 2025-04-09 at 18 14 14@2x

Sometimes it's not always super clear why errors are there, for example 02_hello_modules.md has:

  • 2.
  • 2.1.1.
  • 2.2.

This throws an error:

Numbering must start at 0 or 1  Expected 0 or 1, but got 2.

And fix will do something a bit confusing like changing this to:

  • 2.
  • 2.1.1.
  • 2.1.

Also for heading re-numbering fixes, you often have to re-run the script a bunch of times as it goes through fixing subsequent headings.

So handle the diff with some care, probably not ready for a bot auto-fix workflow command yet 😅

Hopefully helpful though.

Copy link

netlify bot commented Apr 9, 2025

Deploy Preview for nextflow-training ready!

Name Link
🔨 Latest commit a4bf64c
🔍 Latest deploy log https://app.netlify.com/sites/nextflow-training/deploys/67f6cabe26080800082a2833
😎 Deploy Preview https://deploy-preview-596--nextflow-training.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@adamrtalbot adamrtalbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, very useful.

@vdauwera
Copy link
Collaborator

Looks great, thanks Phil!

@vdauwera
Copy link
Collaborator

@ewels Would you mind adding a short note on usage (especially the --fix usage) in the repo readme?

@vdauwera vdauwera added documentation Improvements or additions to documentation deployment labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants