-
-
Notifications
You must be signed in to change notification settings - Fork 324
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
⭐ Suggestion
Currently, it seems kind doesn't support digits.
For example,
id: test-rule
language: markdown
rule:
kind: atx_h1_markergives
$ ast-grep scan
Error: Cannot parse rule /path/to/rules/foo.yml
Help: The file is not a valid ast-grep rule. Please refer to doc and fix the error.
See also: https://ast-grep.github.io/guide/rule-config.html
✖ Caused by
╰▻ Fail to parse yaml as Rule.
╰▻ `rule` is not configured correctly.
╰▻ Rule contains invalid kind matcher.
╰▻ Invalid Kind
╰▻ Kind `atx_h` is invalid.
The last line implies kind: atx_h1_marker is regarded as kind: atx_h, ignoring the first digit and afterwards.
💻 Use Cases
I'm trying to use ast-grep for linting markdown files.
tree-sitter support is provided by tree-sitter-markdown, and I succeeded to setup the parser:
$ cat 1.md
# section$ tree-sitter parse 1.md
(document [0, 0] - [2, 0]
(section [0, 0] - [2, 0]
(atx_heading [0, 0] - [1, 0]
(atx_h1_marker [0, 0] - [0, 1])
heading_content: (inline [0, 2] - [0, 9]))))I want to match atx_h1_marker.
The current workaround is this:
id: test-rule
language: markdown
rule:
pattern:
context: "# hello"
selector: atx_h1_markerSurprisingly, digits are supported in selector. (I thought selector was the same as kind.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working