Open franke-biosaxs opened 4 months ago
Curiously, name
is listed under Deprecated attributes
; this project has only ever really attempted to target HTML 5.
The single id
rather than href
is interesting, I never knew that. Would the suggestion of setting allow_missing_href = true
work for you though?
Thanks for the quick reply.
I only quoted the name
attribute as it included a description of what it was meant for, i.e. what id
is being used for here. Don't know if this is a common thing to do nowadays, though. I just changed the name
with id
when preparing my texts, out of habit of old when <a name="...">
was the only way to define anchors (that I knew of).
The single
id
rather thanhref
is interesting, I never knew that. Would the suggestion of settingallow_missing_href = true
work for you though?
In the sense of not showing the warning for <a id="...">
yes, it will not show the message. However, I would also not be notified in the rare cases where I might actually have missed to fill in the href
, unfortunately.
To provide context: running html-proofer on my project as-is results in about 2000 failures, by far the most are "'a' tag is missing a reference" messages - I'd guess that at most five of those are actually missing hrefs
and all others are of the <a id="...">
kind. I would have to verify each and every one to find them, though.
Cheers, I've hit this issue as well, with asciidoc
generated HTML pages which also use <a id="token"></a>
anchors and elsewhere the <a href="#token">Some text</a>
references.
Per https://www.w3schools.com/tags/tag_a.asp this is valid, the a
tag accepts "Global Attributes" which include an id
: https://www.w3schools.com/tags/ref_standardattributes.asp
It seems that the <a name=...>
syntax is obsolete (not documented in the page above); Q&A like https://stackoverflow.com/questions/16974480/if-a-name-is-obsolete-what-is-preferred confirm that. The name
attribute is known for some other tags/elements: https://www.w3schools.com/tags/att_name.asp
To answer the additional question above, at least with htmlproofer 3.14.1 (as available in the Ubuntu 22 that I have under hand), and command-line tool usage, the option did not help:
In full form - "needless":
:; htmlproofer --allow_missing_href=true protocols/apcsmart.html
/usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary/program.rb:31:in `go': needless argument: --allow_missing_href=true (OptionParser::NeedlessArgument)
from /usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
from /usr/bin/htmlproofer:11:in `<main>'
In short form - no effect:
:; htmlproofer --allow_missing_href --disable-external protocols/apcsmart.html
Running ["ImageCheck", "LinkCheck", "ScriptCheck"] on protocols/apcsmart.html on *.html...
Ran on 1 file!
print_failed_tests': \e[31mHTML-Proofer found 23 failures!\e[0m (RuntimeError) from /usr/lib/ruby/vendor_ruby/html-proofer/runner.rb:50:in
run'
from /usr/bin/htmlproofer:105:in block (2 levels) in <main>' from /usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in
block in execute'
from /usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in each' from /usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in
execute'
from /usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in go' from /usr/share/rubygems-integration/all/gems/mercenary-0.3.6/lib/mercenary.rb:19:in
program'
from /usr/bin/htmlproofer:11:in `
A variant of the page is available at https://networkupstools.org/protocols/apcsmart.html and links like https://networkupstools.org/protocols/apcsmart.html#R do work in a browser to jump to referred parts of the table etc.
Curiously, I haven't seen complaints about 'a' tag is missing a reference
on the systems I've tried (also checked htmlproofer 3.19.2 on Debian 12).
But given that the current release is 5.0.9, maybe that complaint just appeared "too recently" :)
UPDATE: With a custom-built 5.0.9, it seems to mostly like the existing file (at least, WRT the internal hash links).
I'm new to web page building and am using Jekyll to build static .html from Markdown. This project seems to be the perfect match to check the links in the resulting files. And it found ... way too many (v5.0.8, installed via
gem
).In particular, consider the generated HTML:
Here html-proofer tells me:
The same is true for \<a name="ipsum">Ipsum\</a>.
Although the W3C validator sees no issue with this usage. The mdn web docs state on name/id attributes:
In Issue #746 it was stated that one should rather err on the cautious side with empty href="" tags, and I can see that. However, there is a valid use for \<a> without
href
attribute altogether -- if and only if at least one of thename
orid
attributes are present.