path: root/t/t4018
diff options
authorAsh Holland <>2020-05-02 13:15:43 (GMT)
committerJunio C Hamano <>2020-05-03 01:04:12 (GMT)
commit09dad9256a32affc4a3bc0cf1fa45d5fa6f51231 (patch)
tree077894ab6bd3dc84f7c030d2aec50c0847311d61 /t/t4018
parente870325ee8575d5c3d7afe0ba2c9be072c692b65 (diff)
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 <> 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 <> Acked-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/t4018')
2 files changed, 23 insertions, 0 deletions
diff --git a/t/t4018/markdown-heading-indented b/t/t4018/markdown-heading-indented
new file mode 100644
index 0000000..1991c2b
--- /dev/null
+++ b/t/t4018/markdown-heading-indented
@@ -0,0 +1,6 @@
+Indented headings are allowed, as long as the indent is no more than 3 spaces.
+ ### RIGHT
+- something
+- ChangeMe
diff --git a/t/t4018/markdown-heading-non-headings b/t/t4018/markdown-heading-non-headings
new file mode 100644
index 0000000..c479c1a
--- /dev/null
+++ b/t/t4018/markdown-heading-non-headings
@@ -0,0 +1,17 @@
+Headings can be right next to other lines of the file:
+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:
+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.