tpope / vim-markdown

Vim Markdown runtime files
1.22k stars 191 forks source link

Update header pattern to include trailing space #168

Closed gpanders closed 4 years ago

gpanders commented 4 years ago

According to the CommonMark spec, ATX headings must be followed by a space, i.e.

# This is a heading
#this is not a heading

The spec also allows 1-3 leading spaces before a header:

   # foo

This updates the syntax file to match these requirements.

tpope commented 4 years ago
This heading has a hard tab, not a space, and works fine
gpanders commented 4 years ago

You're right, I just tested the same thing with cmark and I get the same result. The spec is pretty explicit about the # character being followed by a space, where "space" is U+0020, so I'm not sure if this is an oversight in the specification or a bug in the implementation (my guess is the former). I've opened an issue with cmark to ask this question, but for the time being I'll update the syntax file to match "any whitespace".

EDIT: From the linked issue:

The current version in master already reads: "The opening sequence of # characters must be followed by spaces or tabs, or by the end of line."

So this is fixed, just not yet in a release.

tpope commented 4 years ago

CommonMark is a retroactive attempt to standardize Markdown. For the purposes of vim-markdown, it's a useful reference but secondary to real world implementations.