Looking for double quotes inside Jinja tags
Hi, thanks for the excellent tool! When running on Jinja2 templates it generally works pretty well. However, when there is an if statement inside a tag this error comes up -

The html is:
<!DOCTYPE HTML>
<option value="{{ t.id }}" {% if t.id == s.type_id %}selected{% endif %}>{{ t.name }}</option>
and run htmlhint:
npx htmlhint test.html
Is there a way that at htmlhint can ignore what is inside a {% ... %} and {{ ... }} ?
I'm going to pin on a few other items related to jinja2 templates - maybe they are related. If not, I can open separate issues.
Tag Pair & Spec Char Escape

Having an {% if %} ... {% endif %} inside an option tag, and any where inside the contents of a section tag seem to throw the "Tag Pair" errors.
Having a > after %} or }} seems to cause the Spec Char Escape error.
You can see that when I remove the if statement there are no errors on the line.
HTML:
<!DOCTYPE HTML>
<option value="w" {% if p.type == "w" %}selected{% endif %}>week(s)</option>
<option value="w" selected>week(s)</option>
Attr Lowercase
When None is inside an if, inside a tag htmlhint expects it to be lowercase.

If contents of {% ... %} and {{ ... }} are ignored this error would go away.
HTML:
<!DOCTYPE HTML>
<option {% if t.type == None %}disabled{% endif %}>Other</option>
<option disabled>Other</option>
Attr No Duplication & Attr Must Have A Value
This error is thrown whenever a {% ... %} or {{ ... }} occurs inside a tag. For example:
<option value="{{ t.id }}" {% if t.id == s.id %} selected {% endif %}>
Expected:
{%, {{, %}, }} should not be considered attribute names.
Attr No Unnecessary Whitespace
This seems too be through when there is whitespace around the connects of an if statement -
%} selected {%
I'm not experienced in TS, but I created pull request #586 that seems to correct all these issues by stripping the tags from the attributes.
Any thoughts or ways this could potentially go wrong?
Thanks!
I think my fix causes issues w/ items like this:
<link href="{{ my_href_var }}" rel="shortcut icon" />
will now trigger the src-not-empty error.
I'll tweak the pr to only trip tags that have a leading white space and see how that helps.
Maybe you can give a tip - most of the tests seem to be passing now, when I have valid template tags, except this one is still triggering the tag-pair and the spec-char-escape which go hand in hand in this. Do you have any ideas what is causing it?
<option value="w" {% if p.type == "w" %} selected="selected" {% endif %}>week(s)</option>
output:
test.html: line 2, col 81, error - Tag must be paired, no start tag: [ </option> ] (tag-pair)
test.html: line 2, col 1, error - Special characters must be escaped : [ < ]. (spec-char-escape)
test.html: line 2, col 73, error - Special characters must be escaped : [ > ]. (spec-char-escape)
Great tool, and ditto on a request for this feature. I'm using nunjucks templates, which is basically the same syntax as jinja. Although I'm wondering if it might be better to add to the rc file definition some sort of way to express file-extension-specific overrides, for example something like:
fileTypeOverrides: {
fileExtension: ".njk",
ignoreBetween: [{
start: "{%",
end: "%"
}, {
start: "{{",
end: "}}"
}],
extraRules: [] // for example in templates I might want do disable missing doctype tag as these are merely html snippets....
}
anyway, just my two cents. I figure that might make it easier to support all sorts of html template syntaxes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Not stale... can any of the devs chip in?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@christopherpickering I "unstale" it, it should not go to stale anymore 😉
Thanks 😁 Is this something you can consider investigating?