Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ root = true
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.txt]
# Some test files have intentional whitespace at EOL.
trim_trailing_whitespace = false

[*.{json,toml,yml,gyp}]
indent_style = space
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Overview
nature; parsing the contents would require loading a "child" language
(injection). See [#2](https://github.com/neovim/tree-sitter-vimdoc/issues/2).
- the terminating `<` (and any following whitespace) is discarded (anonymous).
- `url` intentionally does not capture `.,)` at the end of the URL. See also [Known issues](#known-issues).
- `h1` = "Heading 1": `======` followed by text and optional `*tags*`.
- `h2` = "Heading 2": `------` followed by text and optional `*tags*`.
- `h3` = "Heading 3": UPPERCASE WORDS, followed by optional `*tags*`, followed
Expand All @@ -45,8 +46,11 @@ Known issues
- Spec requires that `codeblock` delimiter ">" must be preceded by a space
(" >"), not a tab. But currently the grammar doesn't enforce this. Example:
`:help lcs-tab`.
- `url` doesn't handle _surrounding_ parens. E.g. `(https://example.com/#yay)` yields `word`
- `url` doesn't handle _nested_ parens. E.g. `(https://example.com/(foo)#yay)`
- `url` cannot contain a closing bracket `]` anywhere in the URL. (Workaround:
URL-encode the bracket.) This is a tradeoff so that markdown hyperlinks work:
```
[https://example.com](https://example.com)
```
- `column_heading` currently only recognizes tilde `~` preceded by space (i.e.
`foo ~` not `foo~`). This covers 99% of :help files.
- `column_heading` children should be plaintext, but currently are parsed as `$._atom`.
Expand All @@ -55,8 +59,8 @@ Known issues
TODO
----

- `tag_heading` : line(s) containing only tags, typically implies a "heading"
before a block.
- `h4` ("tag heading") : a line containing only tags, or ending with a tag, is
a "h4" heading.

Release
-------
Expand Down
7 changes: 5 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = grammar({
$._atom_common,
),
word: ($) => choice(
token(prec(-1, /[^,(\[\n\t ]+/)),
token(prec(-1, /[^.,(\[\n\t ]+/)),
$._word_common,
),

Expand Down Expand Up @@ -89,11 +89,14 @@ module.exports = grammar({
/\{\{+[0-9]*/,

'(',
')',
'[',
']',
'~',
// NOT codeblock: random ">" in middle of the motherflippin text.
'>',
',',
'.',
),

note: () => choice(
Expand Down Expand Up @@ -223,7 +226,7 @@ module.exports = grammar({
'*', '*'),

// URL without surrounding (), [], etc.
url_word: () => /https?:[^\n\t)\] ]+/,
url_word: () => /https?:\/\/[^\n\t\] ]*[^\n\t )\].,]/,
url: ($) => choice(
// seq('(', field('text', prec.left(alias($.url_word, $.word))), token.immediate(')')),
// seq('[', field('text', prec.left(alias($.url_word, $.word))), token.immediate(']')),
Expand Down
16 changes: 14 additions & 2 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading