-
Notifications
You must be signed in to change notification settings - Fork 528
comply with WCAG 2.0 for footnote backlinks #313
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
Conversation
WCAG 2.0 2.4.4 says link texts to different urls cannot be the same. aria-label matching the title attribute is probably redundant and doesn't solve the issue, so this implementation allows for user-overridable aria-labels with reference and footnote number reference options to comply with 2.4.4
Changes to the default behavior are: the aria-label is no longer included on the footnote backlinks when the |
I believe the problem you're trying to solve is the repeated Is there a good reason why the label should be different from the title? Adding a configuration variable allowing the text to be different makes things more complicated to configure, and adds more logic to test and maintain. I'd rather avoid it if possible. We could fix title generation instead. It might look fine to say "Go back to reference 1 of footnote 1" when there is more than one footnote reference. But most of the time there is only one footnote per reference, and in such a situation this text is far from ideal. I think it should say ""Go back to reference of footnote 1", skipping the reference index since there's only one. So I think we need a different string for cases where there more than one reference. About the implementationThe note id is just an identifier for generating the What you probably want is the footnote number. You'll need a counter in the |
Yes, the problem is that to pass WCAG 2.0 checks (which is required by law for US Government and Public sector, e.g., education), you cannot have multiple links with the same link text which lead to different URLs. See WCAG 2.0, 2.4.4 (level A) and 2.4.9 (level AAA). If you have more than one footnote (or multiple footnote references to the same footnote), that creates multiple return arrow links (which is therefore the same link text leading to different URLs and the hash portion counts as part of the URL in this case). You can get around the same link text issue by providing a unique aria-label (or title) which keeps the visual aspect but positively affects the accessibility DOM. The footnote markers themselves (sup 1, 2, 3) are fine because they all lead to their respective same URLs. I fully agree that it adds complexity to the implementation but I didn't want to hard-code any sort of aria-label because that limits the text to English and to a specific phrase format. Using those {ref} and {fn} placeholders in an optional user-definable label allows for localization of the aria-label for the back reference. I generally use numeric references so I didn't test with a named reference. I'll fix that and create a new PR with your suggested internal variable. I will also fix a bug I noticed which allows for spaces in named footnote references which creates an invalid id value. I understand your reticence to adding complexity to the code for an admittedly rarely used issue, but you already have some accessibility built-in with the aria roles and the aria-label so I feel going the extra step for a11y compliance is worth it. Plus, for those of us that have a critical/lawful need, it will save a considerable amount of headache if we want to keep using your fantastic tool. I hope you will consider it. |
As to the |
whitespace creates invalid HTML ids
refer to the internal footnote number instead of the named reference id
I've pushed updates (which I guess should have been separate PRs--sorry) to address the footnote reference number and the issue with named footnotes with spaces in them. |
Just to cite a reference, the WHATWG docs on the |
invalidating spaces in footnote names, while technically correct from HTML standards point of view is an unnecessarily burdensome breaking change at this time
Indeed, there are other characters that php-markdown accepts as valid footnote names which make them invalid from an HTML standards perspective that, were such a change to be made, it should be a more comprehensive implementation and transparent to the user without the need for additional documentation unless absolutely warranted. I hope that you will still give serious consideration the |
Ok. I agree we should fix this. Here's two guidelines I'd like to be followed:
Here's what I had in mind for the configuration variables:
Which someone would configure this way:
Does that make sense? Hopefully I'm not pilling up too much work on you by suggesting this. Feel free to skip some parts if you want. And I used |
While I prefer named replacement parameters because they're self-documenting, I also appreciate consistency. What if I implement both But, because these are programmer-side, I don't think it's too onerous to keep them simple and consistent but opaque in use/meaning. As for all the extra variables, it sort of rubs me the wrong way but I'm trying to think of a more elegant solution that isn't troublesome.
Using special characters to denote optional regions could start to get messy because of the need to escape control characters. That can get ugly quick. I'm talking it out before coding, in case you have any particular feedback or ideas. |
I kind of prefer
This may make it easier to remember that |
I do like From a localization perspective, two separate strings will generally work better than a string pattern of some kind because adaptation might be needed to suite the grammatical rules. |
And I'm not brining localization issues as a way to discourage exploration into other solutions than having two variables, just as something to keep in mind. |
You're right. There are too many variations in language grammars that a single variable with a parsed syntax could be problematic. I'll stick with multiple variables and the simpler |
Considering the duality of the double variable with fallback solution, I'm thinking what happens when one or either or both vars are blanks. I will refer to the single variable as, for example,
|
That logic looks fine. Omitting the link altogether when the HTML is empty would make sense. I don't know if anyone depends on that behavior currently, but I'd find that surprising. On the other hand, I wonder if this is only adding flexibility for the sake of adding flexibility as I expect no one will use the feature. I don't have a definitive answer, so I'll let you decide. |
…, html also, no (empty) backlink is generated when the $fn_backlink_html is blank
I think the footnote backlinks parsing feature is going to be rarely used, even if it is critical to those of us who need it. A simpler implementation should be fine for now. |
WCAG 2.0 2.4.4 (and 2.4.9) says link texts to different URLs cannot be the same. Using aria-label which matches the title attribute is probably redundant and doesn't solve the issue. This implementation allows for user-overridable aria-labels with reference and footnote number reference options to comply with 2.4.4 and 2.4.9.
This PR also includes an .editorconfig file to help maintain source formatting options across multiple editors/contributors.