Skip to content

no-ambiguous-ampersand

Reports an & in text that starts no character reference (a & b), and a raw < in text where it is not a syntax error, such as the Hugo shortcode {{<. A > is the rule no-raw-gt.

A lone & renders as written, but it turns into a different character the day the text after it spells an entity, and some tools reject it.

To fix, write &amp; for the & and &lt; for the <.

Reported
...
<title>t</title>
...
<p>a &gt; b &amp; &#38;</p>
<p>Ham & Shroom</p>
<p>one
...
<script>if (a > b) {}</script>
...
angular:
lint:
rules:
no-ambiguous-ampersand: warn # off (default), warn, error
html:
lint:
rules:
no-ambiguous-ampersand: warn # off (default), warn, error
svelte:
lint:
rules:
no-ambiguous-ampersand: warn # off (default), warn, error
vue:
lint:
rules:
no-ambiguous-ampersand: warn # off (default), warn, error

Enabled by the presets: html/html-validate-recommended.

Suppress one line with sudsy-disable-next-line no-ambiguous-ampersand in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
html-validate no-raw-characters partial a lone & is no-ambiguous-ampersand, a raw < the parser’s syntax-error; html-validate does not report a >; the relaxed option is not available