-
Notifications
You must be signed in to change notification settings - Fork 18
remove scanner, rewrite grammar.js #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
tree-sitter-vimdoc | ||
================== | ||
|
||
This grammar intentionally support a subset of the vimdoc "spec"; predictable | ||
results are the primary goal, so that _output_ formats (e.g. HTML) are | ||
well-formed; the _input_ (vimdoc) is secondary. The first step should always be | ||
to try to fix the input (within reason) rather than insist on a grammar that | ||
handles vimdoc's endless quirks. | ||
|
||
Notes | ||
----- | ||
|
||
- vimdoc format "spec": | ||
- [:help help-writing](https://neovim.io/doc/user/helphelp.html#help-writing) | ||
- https://github.com/nanotee/vimdoc-notes | ||
- whitespace is intentionally captured in `(word)`, because it is often necessary to be | ||
able to correctly layout vim help files (especially old/legacy). | ||
- `(codeblock)` is contained by `(line)` because `>` can start a code block at the end of a line. | ||
- `(column_heading)` is contained by `(line)` because `>` (to close | ||
a `(codeblock)` can appear at the start of `(column_heading)`. | ||
- `h1` ("Heading 1"): `======` followed by text and optional `*tags*`. | ||
- `h2` ("Heading 2"): `------` followed by text and optional `*tags*`. | ||
- `h3` ("Heading 3"): only UPPERCASE WORDS, followed by optional `*tags*`. | ||
|
||
Known issues | ||
------------ | ||
|
||
- `line_li` ("list item") is _experimental_. It doesn't support nesting yet and | ||
it may not work well; you can treat it as a normal `line` for layout purposes. | ||
- `codeblock` ">" must not be preceded only by tabs, a space char is required (" >"). | ||
See `:help lcs-tab` for example. Currently the grammar doesn't enforce this. | ||
- `codeblock` terminated by an "implicit stop" (i.e. no terminating `<`) | ||
consumes the first char of the terminating line, and continues the parent | ||
`block`, preventing top-level forms like `h1`, `h2` from being recognized | ||
until a blank line is encountered. | ||
- `line` in a `codeblock` does not contain `word` atoms, it's just the full | ||
raw text line including whitespace. This is somewhat dictated by its | ||
"preformatted" nature; parsing the contents would require loading a "child" | ||
language (injection). See [#2](https://github.com/vigoux/tree-sitter-vimdoc/issues/2). | ||
- `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)` | ||
- Ideally `block_end` should consume the last block of the document _only_ if that | ||
block is missing a trailing blank line or EOL ("\n"). | ||
- TODO: consider simply _not supporting_ docs without EOL? | ||
- Ideally `line_noeol` should consume the last line of the document _only_ if | ||
that line is missing EOL ("\n"). | ||
- TODO: consider simply _not supporting_ docs without EOL? | ||
|
||
TODO | ||
---- | ||
|
||
- `line_noeol` is a special-case to support documents that don't end in EOL. | ||
Grammar could be a bit simpler if we just require EOL at end of document. | ||
- `line_modeline` (only at EOF) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,53 @@ | ||
================================================================================ | ||
Simple argument | ||
simple argument | ||
================================================================================ | ||
This in an argument: {arg} | ||
-------------------------------------------------------------------------------- | ||
|
||
(help_file | ||
(line | ||
(word) | ||
(word) | ||
(word) | ||
(word) | ||
(argument | ||
(word)))) | ||
(block | ||
(line | ||
(word) | ||
(word) | ||
(word) | ||
(word) | ||
(argument | ||
(word))))) | ||
|
||
================================================================================ | ||
Multiple arguments on the same line | ||
multiple arguments on the same line | ||
================================================================================ | ||
|
||
{foo} {bar} {baz} | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(help_file | ||
(line | ||
(argument | ||
(word)) | ||
(argument | ||
(word)) | ||
(argument | ||
(block | ||
(line | ||
(argument | ||
(word)) | ||
(argument | ||
(word)) | ||
(argument | ||
(word))))) | ||
|
||
================================================================================ | ||
NOT an argument | ||
================================================================================ | ||
{foo "{bar}" `{baz}` |{baz| } {} | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(help_file | ||
(block | ||
(line | ||
(argument | ||
(word) | ||
(ERROR)) | ||
(word) | ||
(codespan | ||
(word)) | ||
(taglink | ||
(word)) | ||
(word) | ||
(word)))) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave up on this for now, ideally it should be: