Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Tag and string punctuation is not targetable in the tree-sitter grammar #224

Closed
1 task done
Aerijo opened this issue Jan 18, 2019 · 5 comments · Fixed by #231
Closed
1 task done

Tag and string punctuation is not targetable in the tree-sitter grammar #224

Aerijo opened this issue Jan 18, 2019 · 5 comments · Fixed by #231

Comments

@Aerijo
Copy link

Aerijo commented Jan 18, 2019

Prerequisites

Description

With the Tree-sitter grammar, there is no scope on the <, </, > and " characters. This means the user / theme cannot target them for custom colours.

Steps to Reproduce

  1. Inspect the scope of one of these characters; it is just text.html.basic source.html
  2. Disable Tree-sitter and refresh the grammar
  3. Inspect the scopes; each can now be targeted independently.

Expected behavior: [What you expect to happen]

Tree-sitter allows equal customisation

Actual behavior: [What actually happens]

No target

Reproduces how often: [What percentage of the time does it reproduce?]

100%

Versions

language-html 0.51.5

Additional Information

See the discuss post for at least one motivation.

@rsese
Copy link

rsese commented Jan 25, 2019

Thanks @Aerijo! I might be misunderstanding so let me know 😄

I tried 1.34.0 with Tree-sitter enabled and your styles from https://discuss.atom.io/t/is-it-possible-to-colorize-the-brackets-of-html-tags-like-in-dreamweaver-and-brackets/62084 and see this:

html-punctuation

Based on your description, I was expecting the brackets to not be affected by the CSS?

@Aerijo
Copy link
Author

Aerijo commented Jan 27, 2019

@rsese You appear to be using the TextMate grammar there (see the console.log statement using the TextMate grammar colours). This will happen if you switch the grammar manually, or there may be something in your config that disabled Tree-sitter for HTML?

The easiest way I know to check is run Editor: Log Cursor Syntax Tree Scope. If it's a list of words, it's a TS grammar. If it's scopes, it's TM.

@rsese
Copy link

rsese commented Jan 28, 2019

Ohhh yeah you're right 👍 I have to manually select HTML with the grammar selector for that particular example file I was using to have it use the Tree-sitter grammar (I didn't see anything in my config for HTML...). If I close and reopen it, I have to manually select HTML again (doesn't seem to happen if I remove the <script> tag though).

In any case, thanks for explaining 👍

@rsese rsese added the triaged label Jan 28, 2019
@lee-dohm lee-dohm changed the title Missing CSS selectors on tag and string punctuation Tag and string punctuation is not targetable in the tree-sitter grammar Jan 29, 2019
@PlaidPhantom
Copy link

Let me know if this needs to be a new ticket, but entities (e.g. &nbsp;) are not targetable either.

@savetheclocktower
Copy link
Contributor

@PlaidPhantom, I'd say that would require a new ticket because the fix isn't as straightforward.

The underlying problem there is that tree-sitter-html doesn't mark entities as entities. Consider:

<p>Lorem ipsum dolor &nbsp; sit amet</p>

The tree-sitter-html parser will mark the entire Lorem ipsum dolor &nbsp; sit amet section as text, but would apply no further markings. It appears that the parser has not considered entities at all.

I'd suggest you open a ticket against tree-sitter-html to find out if the omission is intentional or if it's just not yet implemented. My guess is the latter. (If it's an intentional omission, then I think language-html could implement the highlighting of entities as an injection grammar with some effort.)

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

Successfully merging a pull request may close this issue.

4 participants