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

[Syntax Highlight] Unexpected syntax colouring inside HTML attribute quotes #93

Open
1 of 4 tasks
replete opened this issue Jul 10, 2024 · 3 comments
Open
1 of 4 tasks

Comments

@replete
Copy link

replete commented Jul 10, 2024

Describe the bug
When using an antler tag contains a string (in example using a ternary operator) within an HTML attribute value, it displays error type syntax highlighting.

It appears the same with all extensions disabled, so I thought it would make sense to fix it within this plugin?

Impacted Products
Which Antlers Toolbox products does this bug apply to?

  • Antlers Toolbox for VS Code
  • Formatter CLI
  • Antlers Prettier Plugin
  • Antlers Syntax Highlighting (external systems - not VS Code)

Versions and Other Plugins/Extensions
vscode v1.91.0

To Reproduce
This HTML shows the problem:
Screenshot 2024-07-10 at 12 17 26

Expected behavior

  • within { is_current ? 'aria-current="page"' : '' }} I would expect 'aria-current="page"' and '' to not be highlighted differently to other values, it appears to me red like an error but is valid syntax. The antlers code works as expected in the application.

If submitting a formatting bug, please include the template contents below as well as an attachment

<nav aria-label="Main Navigation" role="navigation">
	<ul>
		{{ nav:main }}
		<li class="{{ is_current || is_parent ? 'active' : '' }}">
			<a href="{{ url }}" class="tx-lg font-bold mr-1" {{ is_current ? 'aria-current="page"' : '' }}>{{ title }}</a>
		{{ /nav:main}}
		</li>
	</ul>
</nav>

(wont allow me to attach an html file for some reason)

Additional context
Thank you for making this extension 👍

@replete
Copy link
Author

replete commented Jul 10, 2024

Another example which I suspect is related
Screenshot 2024-07-10 at 12 31 23

{{ elseif type == "youtube_embed" }}
	<div class="youtube-video-container">
		<iframe
			width="560"
			height="315"
			src="{{ url | replace('watch?v=','/embed/') }}"
			frameborder="0"
			allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
			allowfullscreen
			>
		</iframe>
	</div>

@replete
Copy link
Author

replete commented Jul 10, 2024

Another related example that causes a CSS parsing error in vscode:
Screenshot 2024-07-10 at 12 34 48

{{hero_carousel}}
{{if type == "hero_panel"}}
	<li style="background-image: url('{{ glide :src="background_image" w="1920" format="webp" }}');" class="{{index == 0 ? 'active': ''}}" id="{{ name | slugify }}-panel">
		<h1>{{ headline }}</h1>
		<h2>{{ sub_headline }}</h2>
		<a href="javascript:void(0);" style="background:#fff; padding:8px; color:var(--brand); text-shadow:none;">{{ link_text }}</a>
	</li>
{{/if}}
{{/hero_carousel}}

When I remove this line, the problem disappears:
<li style="background-image: url('{{ glide :src="background_image" w="1920" format="webp" }}');" class="{{index == 0 ? 'active': ''}}" id="{{ name | slugify }}-panel">

This works the same way with all extensions disabled.

Screenshot 2024-07-10 at 12 36 27

I hope this is a helpful bug report. Thanks for putting this out there once again, I certainly appreciate the challenges you have overcome with this tricky syntax.

@replete replete changed the title [Syntax Highlight] Unexpected syntax colouring inside HTML attribute quotes using ternary operator [Syntax Highlight] Unexpected syntax colouring inside HTML attribute quotes Jul 10, 2024
@JohnathonKoster
Copy link
Contributor

JohnathonKoster commented Jul 10, 2024 via email

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