Skip to content

Latest commit

 

History

History
107 lines (67 loc) · 2.29 KB

File metadata and controls

107 lines (67 loc) · 2.29 KB

MD026 - Trailing punctuation in heading

Tags: headings

Aliases: no-trailing-punctuation

Fixable: Some violations can be fixed by tooling

Description

This rule is triggered on any heading that has one of the specified normal or full-width punctuation characters as the last character in the line:

# This is a heading.

To fix this, remove the trailing punctuation:

# This is a heading

Parameters

  • punctuation: Punctuation characters (string, default .,;:!。,;:!)

Configuration

The punctuation parameter can be used to specify what characters count as punctuation at the end of a heading. For example, you can change it to ".,;:" to allow headings that end with an exclamation point. ? is allowed by default because of how common it is in headings of FAQ-style documents. Setting the punctuation parameter to "" allows all characters - and is equivalent to disabling the rule.

Example configuration:

[linters.severity]
no-trailing-punctuation = "err"

[linters.settings.no-trailing-punctuation]
punctuation = ".,;:"  # Custom punctuation (excludes ! and full-width chars)

Exceptions

The trailing semicolon of HTML entity references like ©, ©, and © is ignored by this rule.

GitHub emoji codes (gemoji) like :smile: and :heart: are also ignored by this rule.

Rationale

Headings are not meant to be full sentences. More information: Punctuation at the end of headers.

Examples

Valid

# This is a good heading

## Another good heading

### FAQ: What is this?

#### How do I use this?

##### Copyright © 2023

###### Happy face :smile:

Invalid

# This heading has a period.

## This heading has an exclamation!

### This heading has a comma,

#### This heading has a semicolon;

##### This heading has a colon:

###### Multiple periods...

Setext headings

Both ATX and setext style headings are checked:

This is invalid.
================

This is also invalid!
---------------------