Skip to content

Commit dc385fb

Browse files
committed
workflows: add and configure a Markdown linter
Signed-off-by: Luca Zeuch <[email protected]>
1 parent 28b6362 commit dc385fb

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

.github/workflows/lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'content/**/*.md'
7+
8+
jobs:
9+
lint-markdown:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Lint markdown files
15+
uses: actionshub/markdownlint@main
16+
with:
17+
filesToIgnoreRegex: 'all-commands.md|scripts/.*|.github/.*'

.mdlrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
git_recurse true
2+
ignore_front_matter true
3+
style 'config/markdownlint.rb'

config/markdownlint.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Enable all rules; we'll configure some of them below.
2+
all
3+
4+
# MD001: Header levels should only increment by one level at a time.
5+
# Normally, this is a fair rule, but it does not quite work for our cases,
6+
# especially in our humongous functions list. So disable it.
7+
exclude_rule 'MD001'
8+
9+
# MD002: First header should be a top level header.
10+
# Some files do not have a top-level header, because it doesn't make sense for
11+
# them, or just looks incredibly stupid on the rendered page. So disable this
12+
# entire rule.
13+
exclude_rule 'MD002'
14+
15+
# MD004: Unordered list style.
16+
# Use dashes for unordered lists. All lists. Even sublists.
17+
rule 'MD004', :style => :dash
18+
19+
# MD013: Line length.
20+
# Allow lines to be up to 120 characters long, see the .editorconfig file.
21+
# We also ignore code blocks, because they are often long and should not be
22+
# wrapped at all. Same goes for tables.
23+
rule 'MD013', :line_length => 120, :ignore_code_blocks => true, :tables => false
24+
25+
# MD024: Multiple headers with the same content.
26+
# Allow multiple headers with the same content so long they are under different
27+
# parent headers.
28+
rule 'MD024', :allow_different_nesting => true
29+
30+
# MD026: Trailling punctuation in header.
31+
# Allow question marks (FAQ-style).
32+
rule 'MD026', :punctuation => '.,;:!'
33+
34+
# MD029: Ordered list item prefix.
35+
# Should increase in numerical order.
36+
rule 'MD029', :style => :ordered
37+
38+
# MD033: Inline HTML.
39+
# Allow certain HTML elements, because we use them for nicer page layout.
40+
rule 'MD033', :allowed_elements => 'center, div, sup, br, kbd'
41+
42+
# MD037: Spaces inside emphasis markers.
43+
# This rule is broken. See https://github.com/markdownlint/markdownlint/issues/84
44+
exclude_rule 'MD037'
45+
46+
# MD041: First line in file should be a top-level header.
47+
# See comment to MD002. It makes no sense to set this to H2 for similar reasons,
48+
# we have TOML frontmatter with an automatic h1 in the rendered page.
49+
exclude_rule 'MD041'

0 commit comments

Comments
 (0)