Always use atx-style headings (not closed) instead of Setext. The level can be easily seen and the number of characters must not match in both lines. ATX also works for all levels, while Setex only goes up to level 2.
remark-lint: heading-style
⇣ Incorrect code for this rule:
Winter
======
Frost
-----
No closed ATX styled headings:
# Winter #
## Frost ##
### Snow ###
⇡ Correct code for this rule:
# Winter
## Frost
### Snow
Always surround headers by a single empty line except at the beginning of the file.
⇣ Incorrect code for this rule:
... snowflakes are falling.
# Winter
Sparkling and frozen...
... snowflakes are falling.
# Winter
Sparkling and frozen...
⇡ Correct code for this rule:
... snowflakes are falling.
# Winter
Sparkling and frozen...
Always separate the marker character #
from the actual header content using a single whitespace.
remark-lint: no-heading-content-indent
⇣ Incorrect code for this rule:
#Winter
# Winter
⇡ Correct code for this rule:
# Winter
Make sure that there are no other characters (including whitespaces) in front of headings.
remark-lint: no-heading-indent
Note: The ·
character represents a whitespace character.
⇣ Incorrect code for this rule:
.# Winter
·# Winter
⇡ Correct code for this rule:
# Winter
Avoid using two or more headers with the same content in the same markdown file. many Markdown renderer generate IDs for headers based on the header content.
remark-lint: no-duplicate-headings and no-duplicate-headings-in-section
⇣ Incorrect code for this rule:
# Winter
## Snow
# Arctic
## Snow
⇡ Correct code for this rule:
# Winter
## Winter Snow
# Arctic
## Arctic Snow
Use an upper case letter as the first letter of a header, unless it is a word that always starts with lowercase letters, e.g. proper names or code snippets. The other letters have the same case they would have in the middle of a sentence.
As an exception, title case can be optionally used for the top-level header. Use this exception sparingly, in cases where typographical perfection is important. Using title case all the time would require too much effort to decide if edge-case words should be upper case or not.
⇣ Incorrect code for this rule:
# winter is sparkling and frozen
Proper names or code snippets:
# react
# `String`
# Init
⇡ Correct code for this rule:
# Winter is sparkling and frozen
Proper names or code snippets:
# React
# `string`
# init main
Prefer using short header with a maximum length of 80 character (without markers). Instead of using a huge sentence, make the header a summary and write the huge sentence as the first paragraph beneath the header. This makes it is easier to refer to the header later, specially if automatic IDs or a TOC are created.
remark-lint: maximum-heading-length
⇣ Incorrect code for this rule:
# The winter is sparkling and frozen and soft snowflakes are falling down on the world!
⇡ Correct code for this rule:
# Winter
The winter is sparkling and frozen and soft snowflakes are falling down on the world!
Don't use any punctuation at the end of a header e.g. a trailing (semi)colon ;:
, period .
, closing marker #
or any "sentence amplifier" (!?
). Every header is an introduction to what is about to come next, which is exactly the function of a colon. Also the header is not a sentence, or at least only a short sentence, so there is not need to add a sentence separator to it.
remark-lint: no-heading-punctuation
⇣ Incorrect code for this rule:
# Winter: Sparkling
# Winter. Frozen.
# Winter #
⇡ Correct code for this rule:
# Winter
Sparkling and frozen.