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

Distinguish between missing and empty attributes #160

Closed
mietek opened this issue Jan 29, 2015 · 14 comments
Closed

Distinguish between missing and empty attributes #160

mietek opened this issue Jan 29, 2015 · 14 comments

Comments

@mietek
Copy link

mietek commented Jan 29, 2015

Currently, the error anchor has no href attribute is triggered both when a tag is missing the href attribute, and when the href attribute is empty:

<a href="" title="Menu">Menu</a>

My projects use empty href attributes for JS-only navigation buttons. Should using an empty href attribute trigger an error?

@gjtorikian
Copy link
Owner

Yes, I think so. Many times I've seen people add placeholder hrefs or srcs, only to forget to fill them out when it's time to ship.

In this case, I'd suggest one of two things:

  1. Add the data-proofer-ignore attribute to the anchors
  2. Pass in an href_ignore that looks like this: [""]. That is, ignore any href with an empty string.

Let me know how it goes!

@mietek
Copy link
Author

mietek commented Jan 30, 2015

Is it possible to pass in that href_ignore from the command-line?

I tried htmlproof --href-ignore "", which had no effect, and htmlproof --href-ignore '""', which failed:

$ htmlproof --href-ignore '""' ./out/pub
Running ["ImageCheck", "LinkCheck", "ScriptCheck"] checks on ./out/pub on *.html... 


Checking 199 external links...
htmlproof 2.0.2 | Error:  wrong number of arguments (2 for 0)

@mietek
Copy link
Author

mietek commented Jan 30, 2015

htmlproof --href-ignore '[""]' also had no effect, but I didn’t expect that to work.

@gjtorikian
Copy link
Owner

Could you try one of the following

htmlproof --href-ignore // ./out/pub
htmlproof --href-ignore '' ./out/pub

That should work:

output = make_bin('--href-ignore /^http:\/\//,/sdadsad/,../whaadadt.html', ignorableLinks)

If not, hey presto, probably a bug.

@mietek
Copy link
Author

mietek commented Jan 30, 2015

The first one does something odd. The second one has no effect.

$ htmlproof --href-ignore // ./out/pub
Running ["ImageCheck", "LinkCheck", "ScriptCheck"] checks on ./out/pub on *.html... 


Checking 1 external link...
Ran on 21 files!


HTML-Proofer finished successfully.
$ htmlproof --href-ignore '' ./out/pub
Running ["ImageCheck", "LinkCheck", "ScriptCheck"] checks on ./out/pub on *.html... 


Checking 199 external links...
Ran on 21 files!


- ./out/pub/_errors/400.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/403.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/404.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/405.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/414.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/416.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/500.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/501.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/502.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/503.html
  *  anchor has no href attribute (line 23)
- ./out/pub/_errors/504.html
  *  External link https://halcyon.sh/_errors/ failed: 404 No error
  *  anchor has no href attribute (line 23)
- ./out/pub/deploy/index.html
  *  anchor has no href attribute (line 23)
- ./out/pub/deploy/monitor/index.html
  *  anchor has no href attribute (line 23)
- ./out/pub/error.html
  *  anchor has no href attribute (line 23)
- ./out/pub/examples/index.html
  *  anchor has no href attribute (line 27)
- ./out/pub/guide/index.html
  *  anchor has no href attribute (line 25)
- ./out/pub/index.html
  *  anchor has no href attribute (line 182)
  *  anchor has no href attribute (line 23)
- ./out/pub/license/index.html
  *  anchor has no href attribute (line 23)
- ./out/pub/reference/index.html
  *  anchor has no href attribute (line 27)
- ./out/pub/shootout/index.html
  *  anchor has no href attribute (line 919)
  *  anchor has no href attribute (line 193)
  *  anchor has no href attribute (line 307)
  *  anchor has no href attribute (line 326)
  *  anchor has no href attribute (line 423)
  *  anchor has no href attribute (line 444)
  *  anchor has no href attribute (line 558)
  *  anchor has no href attribute (line 27)
  *  anchor has no href attribute (line 676)
  *  anchor has no href attribute (line 694)
  *  anchor has no href attribute (line 791)
  *  anchor has no href attribute (line 820)
  *  anchor has no href attribute (line 170)
  *  anchor has no href attribute (line 943)
  *  anchor has no href attribute (line 1042)
  *  anchor has no href attribute (line 1065)
  *  anchor has no href attribute (line 1164)
  *  anchor has no href attribute (line 1182)
  *  anchor has no href attribute (line 577)
  *  anchor has no href attribute (line 1306)
  *  anchor has no href attribute (line 1404)
  *  anchor has no href attribute (line 1425)
  *  anchor has no href attribute (line 1524)
  *  anchor has no href attribute (line 1554)
  *  anchor has no href attribute (line 1280)
- ./out/pub/tutorial/index.html
  *  anchor has no href attribute (line 86)
  *  anchor has no href attribute (line 140)
  *  anchor has no href attribute (line 221)
  *  anchor has no href attribute (line 320)
  *  anchor has no href attribute (line 338)
  *  anchor has no href attribute (line 433)
  *  anchor has no href attribute (line 453)
  *  anchor has no href attribute (line 539)
  *  anchor has no href attribute (line 695)
  *  anchor has no href attribute (line 27)
htmlproof 2.0.2 | Error:  HTML-Proofer found 56 failures!

@gjtorikian
Copy link
Owner

The first one does something odd.

I don't know what your output looks like, so that might not be so odd after all:

  • Assuming that you have 21 files in your output, HTML-Proofer found them all
  • Assuming that all of your hrefs are "". HTML-Proofer ignored them all
  • Assuming that there's just one external link, HTML-Proofer found it, and validated it with a success

@mietek
Copy link
Author

mietek commented Jan 30, 2015

You can see my output published on https://halcyon.sh. 199 external links sounds about right.

@gjtorikian
Copy link
Owner

My suspicion is that there are, indeed, 199 href tags. And most of them are empty. That's what --href-ignore // is doing--you're asking to ignore the empty hrefs from the check. Which leaves just one external link that's actually real.

Internal hrefs are not presented as part of the original run summary:

$ htmlproof --href-ignore // ./out/pub
Running ["ImageCheck", "LinkCheck", "ScriptCheck"] checks on ./out/pub on *.html... 


Checking 1 external link...
Ran on 21 files!

@mietek
Copy link
Author

mietek commented Jan 30, 2015

I’m pretty sure there’s more than one external link, though. Here’s one try at the non-unique link count:

$ ack --html -ch 'href="http' ./out/pub
481

Full output:
https://gist.github.com/mietek/9e2ce79da6cb1d28a60b

@gjtorikian
Copy link
Owner

Would it be possible to get me a raw dump of the HTML? I would prefer not to crawl the https://halcyon.sh to fetch individual pages.

One thing I forgot to mention is that once a link is checked, it's marked as successful. So, for example, although there are 11 https://halcyon.sh/_errors/, Proofer checks it once, marks it as success, and ignores doing it again. This is for performance reasons.

I'm wondering here if the count is off in the messaging (likely) or if it's really missing the hrefs (less likely).

@mietek
Copy link
Author

mietek commented Jan 30, 2015

@gjtorikian
Copy link
Owner

😻 Thank you! I'll get a fix pushed out later if there is a problem.

@gjtorikian
Copy link
Owner

Can you grab 2.0.3? I tried the following command and everything worked like a charm:

htmlproof --href-ignore /^$/ ./out/pub

Sorry for all the trouble.

@mietek
Copy link
Author

mietek commented Jan 31, 2015

Works perfectly for all my sites. Thank you very much.

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