git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] userdiff: support Markdown

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 30, 2020, 17:31 UTC
Message-ID
<xmqq4kt0ubgu.fsf@gitster.c.googlers.com>
In-Reply-To
<20200429230509.31017-1-ash@sorrel.sh>
Ash Holland <ash@sorrel.sh> writes:
Show 12 quoted lines
> 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/
>
> 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.
> +PATTERNS("markdown",
> +	 "^ {0,3}#{1,6}( .*)?$",

This is "possibly just a bit indented run of up to 6 hashes, either ending the line by itself or if some text follows, there must be a SP after the hashes".

If I had a line that has a hash, HT and then "Hello, world", would everybody's markdown implementation reject it as a header, because the whitespace after the run of hashes is not a SP?

Also, allowing only the hashes might be spec-compliant, but how useful would it be to see just a sequence of 4 hashes without any text after "@@ -100,5, +100,6 @@" in the diff output?

Taking all that together, my suspicion is
	"^ {0,3}#{1,6}[ \t]"

i.e. "possibly slightly indented run of 6 hashes, with a whitespace to catch the headers with real contents and nothing else" might be more practically useful. I dunno.

> +	 "[^<>= \t]+"),
This does match the one for HTML.
In any case, let me queue this v2 as-is and see what happens.
Thanks.
Previous: Ash HollandNext: Ash Holland
Message 11 of 15 in “userdiff: support Markdown”
  1. userdiff: support MarkdownAsh Holland, Apr 21, 2020
  2. Emma BrooksApr 21, 2020
  3. Ash HollandApr 23, 2020
  4. Junio C HamanoApr 28, 2020
  5. Ash HollandApr 29, 2020
  6. Johannes SixtApr 23, 2020
  7. Ash HollandApr 23, 2020
  8. Johannes SixtApr 24, 2020
  9. Ash HollandApr 29, 2020
  10. userdiff: support MarkdownAsh Holland, Apr 29, 2020
  11. Junio C HamanoApr 30, 2020
  12. Ash HollandMay 1, 2020
  13. Johannes SixtMay 1, 2020
  14. userdiff: support MarkdownAsh Holland, May 2, 2020
  15. Johannes SixtMay 2, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.