Skip to content
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

xml-stylesheet tag isn't highlighted and breaks everything that follows #1

Open
kanashimia opened this issue Mar 17, 2024 · 2 comments

Comments

@kanashimia
Copy link

kanashimia commented Mar 17, 2024

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<doc>
  <title>Document Title</title>
  <chapter>
    <title>Chapter Title</title>
    <section>
      <title>Section Title</title>
      <para>This is a test.</para>
      <note>This is a note.</note>
    </section>
    <section>
      <title>Another Section Title</title>
      <para>This is <emph>another</emph> test.</para>
      <note>This is another note.</note>
    </section>
  </chapter>
</doc>

image

The issue was in Helix, they use this grammar as I see.

@datho7561
Copy link

I also just ran into this in Helix. As a work around in Helix, you can set the language to HTML, but it would be nice to fix this grammar.

It seems adding any <? ... ?> construct that isn't the xml one at the beginning of the document breaks parsing.

@datho7561
Copy link

here's the problem: https://github.com/RenjiSann/tree-sitter-xml/blob/main/grammar.js#L79

the spec uses - to represent taking the complement between the two sets. In this case, I think it means any string of length 0 or greater except for any strings of length 0 or greater that contain the substring ?>. However, in the current grammar, it's parsing the literal character -. I can't think of a way to translate the spec into a regex that doesn't use lookahead. I'm guessing the best bet is to use a heuristic like [^?]* to match the processing instruction content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants