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

Create means of including grammar in child context #112

Closed
dead-claudia opened this issue Apr 23, 2019 · 1 comment
Closed

Create means of including grammar in child context #112

dead-claudia opened this issue Apr 23, 2019 · 1 comment

Comments

@dead-claudia
Copy link

Some grammars more or less "extend" grammars that let them:

  • C++ and Objective C already extend C and C just uses $self to recurse.
  • TypeScript really should just extend JS the same way.

But of course, with naïve inclusion, that causes problems.

  • When language-gfm includes language-c, comments and pointer dereferences get interpreted as emphasis.
  • If JS were altered to work like C, var test1 = a < b\nvar test2 = a > c (where \n represents an actual newline) could end up mishighlighted with <b var test2="a"> highlighted as an "element" of sorts that doesn't actually exist.

So I'm thinking a new {includeChild: 'scope'} pattern should exist. This would create a new "root" highlighting context for that subsection. This complements #83 (PR: #90) in that this feature isolates the matched grammar while that feature isolates the matched source. Most use cases would end up using both, so it might be worth merging the two, but I'm not sure if that's all use cases.

@dead-claudia
Copy link
Author

Closing per #90 being closed. This is probably not the ideal way to attack the problem if things are migrating to Tree Sitter.

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

No branches or pull requests

1 participant