Skip to content

Markdown

gspot lints .md and .mdx files with markdownlint, its own check parses the code blocks inside them, and Prettier formats them:

Check Stage Level What it does
markdown/markdownlint commit basic Checks the headings, lists, and spacing of every Markdown file.
markdown/fences commit basic Checks the code blocks of Markdown and MDX files for syntax errors.

Spelling and Prose cover the words of the same files.

gspot starts from the Prettier style of markdownlint, which turns off the rules that Prettier already handles, such as line length and list indentation. Then gspot changes these rules:

Rule Setting
MD018 and MD020 On: a heading needs spaces around its # marks.
MD024 Two headings with the same text get a finding only when they share a parent heading.
MD026 A heading may not end in ., ,, ;, :, or !, or their full-width forms.
MD033 Off: inline HTML is allowed.
MD046 Code blocks must be fenced, not indented.
MD059 Link text of here, this, this page, read more, more, click here, link, documentation, or docs gets a finding.

Level all adds MD041, which asks for a top-level heading on the first line, and MD025, which allows one top-level heading per file. For MD025, gspot sets front_matter_title to an empty string, so a title in the front matter does not count as a top-level heading.

markdownlint skips the front matter of a file. In an .mdx file, the rules start after the leading import and export lines.

markdown/fences parses code blocks in JSON, jsonc, TOML, YAML, Bash, JavaScript, JSX, TypeScript, TSX, and Python, and reports each syntax error at its line:

failed markdown/fences 2 findings
README.md:10 syntax Fix this code example: JSON syntax error: property name expected.
README.md:14 syntax Fix this code example: Syntax error.

The check accepts these shortcuts:

  • It skips a block with a line of only ....
  • (...) reads as an empty argument list.
  • A placeholder such as <name> in a Bash block reads as a word.
  • A JavaScript or TypeScript block may hold an expression or object members instead of a whole program, and a TypeScript block may hold a type. A Python block may hold an expression.

Label a block text when it holds no code.

tools.markdownlint.rules sets the options of a rule that your level runs, and each entry takes an option table. To turn a rule off, ignore it with a reason:

gspot set tools.markdownlint.rules '{ MD024 = { siblings_only = false } }'
gspot ignore markdown/markdownlint --rule MD046 --reason "The changelog quotes indented code from old releases."

gspot turns on mkdocs when an mkdocs.yml or mkdocs.yaml file uses the admonition, pymdownx.details, or pymdownx.tabbed extension. In MkDocs, an admonition, a details block, or a content tab indents its body by four spaces. markdownlint reads such a body as an indented code block, and the link references inside it as unused, so the mkdocs configuration turns off MD046 and MD053.