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

Inject html syntax highlighting via language=html comment #3465

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

fbricon
Copy link
Collaborator

@fbricon fbricon commented Jan 16, 2024

Following up on #3455 to add support for HTML syntax highlighting with a language=html comment.

String HTML = /* language=html */ 
"""
  <!DOCTYPE html>
  <html>
    <body>
      <p style="color:white">
      This paragraph
      contains a lot of lines
      in the source code,
      but the browser 
      
      ignores it.
      </p>
      </body>
  </html>
""";

renders as :

Screenshot 2024-01-16 at 16 11 03

One caveat: invalid closing <script> causes a red semicolon at the end of the declaration:

Screenshot 2024-01-16 at 16 11 26

It uses the HTML Derivative grammar, as it's supposed to better handle malformed HTML specifically for templating purposes, which is exactly what we're doing here.

Signed-off-by: Fred Bricon <fbricon@gmail.com>
@fbricon fbricon added this to the End January 2024 milestone Jan 16, 2024
@rgrunber rgrunber merged commit fa2a63c into redhat-developer:master Jan 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants