Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed Jun 4, 2023
1 parent 5b3c920 commit ef42999
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ Check the playground at <https://stsewd.dev/tree-sitter-comment/>.
Since comment tags aren't a programming language or have a standard,
I have chosen to follow popular conventions for the syntax.

### Comment tags

* Comment tags can contain:
- Upper case ascii letters
- Numbers (can't start with one)
- `-`, `_` (they can't start or end whit these characters)
* Optionally can have an user linked to the tag inside parentheses `()`
* The name must be followed by `:` and a whitespace

### URIs

* http and https links are recognized

If you think there are other popular conventions this syntax doesn't cover,
feel free to open a issue.

Expand All @@ -33,12 +39,37 @@ XXX: extra white spaces.
NOTE-BUG (stsewd): tags can be separated by `-`
NOTE_BUG: or by `_`.
This will be recognized as a URI
https://github.com/stsewd/
```

## FAQ

### Can I match a tag that doesn't end in `:`, like `TODO`?

This grammar doesn't provide a specific token for it,
but you can match it with this query:

```scm
("text" @todo
(#eq? @todo "TODO"))
```

## TODO
### Can I highlight references to issues, PRs, MRs, like `#10` or `!10`?

- Detect links?
- Detect tags that start with `#` (like when linking to a PR)?
This grammar doesn't provide a specific token for it,
but you can match it with this query:

```scm
("text" @issue
(#match? @issue "^#[0-9]+$"))
;; NOTE: This matches `!10` and `! 10`.
("text" @symbol . "text" @issue
(#eq? @symbol "!")
(#match? @issue "^[0-9]+$"))
```

## Why C?

Expand Down
6 changes: 5 additions & 1 deletion test/corpus/source.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ URI: https://user:pass@example.com/org/repo/?foo=baz

(https://example.com/foo/bar/)

URI(me): (https://example.com/foo/bar/?foo=bar)
URI(me): (https://github.com/stsewd/?foo=bar#baz)

--------------------------------------------------------------------------------

Expand All @@ -107,4 +107,8 @@ URI(me): (https://example.com/foo/bar/?foo=bar)
(tag
(name))
(uri)
(uri)
(tag
(name)
(user))
(uri))

0 comments on commit ef42999

Please # to comment.