Skip to content

Commit ef42999

Browse files
committed
Update README
1 parent 5b3c920 commit ef42999

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ Check the playground at <https://stsewd.dev/tree-sitter-comment/>.
1010
Since comment tags aren't a programming language or have a standard,
1111
I have chosen to follow popular conventions for the syntax.
1212

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

22+
### URIs
23+
24+
* http and https links are recognized
25+
2026
If you think there are other popular conventions this syntax doesn't cover,
2127
feel free to open a issue.
2228

@@ -33,12 +39,37 @@ XXX: extra white spaces.
3339
3440
NOTE-BUG (stsewd): tags can be separated by `-`
3541
NOTE_BUG: or by `_`.
42+
43+
This will be recognized as a URI
44+
https://github.com/stsewd/
45+
```
46+
47+
## FAQ
48+
49+
### Can I match a tag that doesn't end in `:`, like `TODO`?
50+
51+
This grammar doesn't provide a specific token for it,
52+
but you can match it with this query:
53+
54+
```scm
55+
("text" @todo
56+
(#eq? @todo "TODO"))
3657
```
3758

38-
## TODO
59+
### Can I highlight references to issues, PRs, MRs, like `#10` or `!10`?
3960

40-
- Detect links?
41-
- Detect tags that start with `#` (like when linking to a PR)?
61+
This grammar doesn't provide a specific token for it,
62+
but you can match it with this query:
63+
64+
```scm
65+
("text" @issue
66+
(#match? @issue "^#[0-9]+$"))
67+
68+
;; NOTE: This matches `!10` and `! 10`.
69+
("text" @symbol . "text" @issue
70+
(#eq? @symbol "!")
71+
(#match? @issue "^[0-9]+$"))
72+
```
4273

4374
## Why C?
4475

test/corpus/source.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ URI: https://user:[email protected]/org/repo/?foo=baz
9292

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

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

9797
--------------------------------------------------------------------------------
9898

@@ -107,4 +107,8 @@ URI(me): (https://example.com/foo/bar/?foo=bar)
107107
(tag
108108
(name))
109109
(uri)
110+
(uri)
111+
(tag
112+
(name)
113+
(user))
110114
(uri))

0 commit comments

Comments
 (0)