0

给定一些 HTML 元素的 tree-sitter 树:

<script>console.log('should parse as js')</script>
<script async defer>console.log('works')</script>
(script_element
  (start_tag 
    (tag_name)) 
  (raw_text
    ; ... etc
  )
  (end_tag
    (tag_name)))
(script_element
  (start_tag
    (tag_name)))
    (attribute 
      (attribute_name))
    (attribute
      (attribute_name))
  (raw_text
    ; ... etc
  )
  (end_tag
    (tag_name)))

损坏的查询

在 neovim 的 tree-sitter html 语法中使用此查询失败injections.scm,返回invalid field错误

(script_element
   (start_tag !attribute))

我将如何查询<script>没有任何属性的元素?语法是否有必要为子项分配一个字段名称以便查询否定它?

4

0 回答 0