git/t/t4018/markdown-heading-non-headings
Ash Holland 09dad9256a userdiff: support Markdown
It's typical to find Markdown documentation alongside source code, and
having better context for documentation changes is useful; see also
commit 69f9c87d4 (userdiff: add support for Fountain documents,
2015-07-21).

The pattern is based on the CommonMark specification 0.29, section 4.2
<https://spec.commonmark.org/> but doesn't match empty headings, as
seeing them in a hunk header is unlikely to be useful.

Only ATX headings are supported, as detecting setext headings would
require printing the line before a pattern matches, or matching a
multiline pattern. The word-diff pattern is the same as the pattern for
HTML, because many Markdown parsers accept inline HTML.

Signed-off-by: Ash Holland <ash@sorrel.sh>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-05-02 18:04:12 -07:00

17 lines
390 B
Text

Headings can be right next to other lines of the file:
# RIGHT
Indents of four or more spaces make a code block:
# code comment, not heading
If there's no space after the final hash, it's not a heading:
#hashtag
Sequences of more than 6 hashes don't make a heading:
####### over-enthusiastic heading
So the detected heading should be right up at the start of this file.
ChangeMe