summaryrefslogtreecommitdiff
path: root/userdiff.c
diff options
context:
space:
mode:
authorAsh Holland <ash@sorrel.sh>2020-05-02 13:15:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-03 01:04:12 (GMT)
commit09dad9256a32affc4a3bc0cf1fa45d5fa6f51231 (patch)
tree077894ab6bd3dc84f7c030d2aec50c0847311d61 /userdiff.c
parente870325ee8575d5c3d7afe0ba2c9be072c692b65 (diff)
downloadgit-09dad9256a32affc4a3bc0cf1fa45d5fa6f51231.zip
git-09dad9256a32affc4a3bc0cf1fa45d5fa6f51231.tar.gz
git-09dad9256a32affc4a3bc0cf1fa45d5fa6f51231.tar.bz2
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>
Diffstat (limited to 'userdiff.c')
-rw-r--r--userdiff.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/userdiff.c b/userdiff.c
index efbe05e..069a828 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -79,6 +79,9 @@ PATTERNS("java",
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
"|[-+*/<>%&^|=!]="
"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("markdown",
+ "^ {0,3}#{1,6}[ \t].*",
+ "[^<>= \t]+"),
PATTERNS("matlab",
/*
* Octave pattern is mostly the same as matlab, except that '%%%' and