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

[html-templating] easy way to inherite advanced html features #49210

Open
samuelcolvin opened this issue May 4, 2018 · 7 comments
Open

[html-templating] easy way to inherite advanced html features #49210

samuelcolvin opened this issue May 4, 2018 · 7 comments
Assignees
Labels
feature-request Request for new features or functionality html HTML support issues
Milestone

Comments

@samuelcolvin
Copy link

With the vscode extension Better Jinja the jinja-html language highlights jinja html templates, however some more advanced features available with the html langauge are not working with jinja-html:

  • highlighting the opening tag when the cursor is in the closing tag (and visa versa) image image In the second case with jinja-html as the language all divs are highlighted, not just the sibling of the tag under the cursor
  • auto creating the closing tag once the opening tag is created.

And probably more, but these are the two which would be most useful.

How do I get these advanced features working in my child language definition?

I've tried copying most of the config from extensions/html/package.json and extensions/html/language-configuration.json into my extension but to no avail. I also tried looking through extensions/html-language-features but there's nothing obvious there to include.

This isn't as simple as adding more file extensions somewhere, even in a .html file if the language is changed to jinja-html the features above disappear.

  • VSCode Version: 1.22.2 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9 x64
  • OS Version: ubuntu 18.04

Steps to Reproduce:

  1. install "Better Jinja"
  2. open or create a file with some html in
  3. change the language to jinja-html
  4. try using advanced html features as described above

Does this issue occur when all extensions are disabled?: Yes (the advanced features work with the html language without extensions, obviously the error can only be shown with the extension installed)

@vscodebot
Copy link

vscodebot bot commented May 4, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@vscodebot vscodebot bot added the html HTML support issues label May 4, 2018
@samuelcolvin
Copy link
Author

sorry, I think this is the same as #2915. There's a lot of noise there so I'm not really sure what the status is of this but I get the impression there's not much I can do at the moment.

@aeschli
Copy link
Contributor

aeschli commented May 4, 2018

To correctly do tag highlighting you need language smarts such as a parser for your language.
If your language syntax is pure/strict HTML (Unfortunately: most templating languages are not) then you could just the same libraries as we use for HTML or even forward all requests to HTML.

There is currently no easy way to easily add advanced HTML features to a template language. #47288 is about documenting the current state and give recommendations.

@aeschli aeschli changed the title advanced html features in languages inheriting from html [html-teplating] easy way to inheriting advanced html features May 4, 2018
@aeschli aeschli changed the title [html-teplating] easy way to inheriting advanced html features [html-templating] easy way to inheriting advanced html features May 4, 2018
@aeschli aeschli added this to the Backlog milestone May 4, 2018
@aeschli aeschli added the feature-request Request for new features or functionality label May 4, 2018
@samuelcolvin samuelcolvin changed the title [html-templating] easy way to inheriting advanced html features [html-templating] easy way to inherite advanced html features Jul 31, 2018
@boonpraserd
Copy link

When I used "Better Jinja", I also used "Auto Close Tag" extension to solve this problem. Please don't forget to edit settings.json by add "jinja-html" to "auto-close-tag.activationOnLanguage".

@angelozerr
Copy link
Contributor

angelozerr commented Apr 1, 2022

@aeschli do you think if I create a pr to support my idea at #131531 (comment) could be acceptable?

I know that it doesnt cover totally this issue but it will give the capability to have a custom language which extends html language features without extra efforts and it will work with language server written in java for instance.

@aeschli
Copy link
Contributor

aeschli commented Apr 4, 2022

@angelozerr Yes, let's work on a PR for that. Can you start by opening a new one so we can discuss the approach in there?

@angelozerr
Copy link
Contributor

@aeschli many thanks for your answer I created the PR at #146731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality html HTML support issues
Projects
None yet
Development

No branches or pull requests

4 participants