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

HeadingPermalinkRenderer Accessibility #1024

Open
ceford opened this issue May 22, 2024 · 4 comments
Open

HeadingPermalinkRenderer Accessibility #1024

ceford opened this issue May 22, 2024 · 4 comments
Labels
enhancement New functionality or behavior

Comments

@ceford
Copy link

ceford commented May 22, 2024

Description

My System - Joomla Accessibility Checker tells me there is a problem with empty links. I fixed it in:

league/commonmark/src/Extension/HeadingPermalink/HeadingPermalinkRenderer.php

by commenting out line 70 so the href attribute does not appear in the anchor. Could that be right?

Example

    //$attrs->set('href', '#' . $fragmentPrefix . $slug);

Did this project help you today? Did it make you happy in any way?

No response

@ceford ceford added the enhancement New functionality or behavior label May 22, 2024
@samwilson
Copy link

You might be better off finding the markdown that contains an empty link (e.g. Lorem [ipsum]() dolor.) and fixing that instead. Or are you saying that CommonMark should never add an href attribute that's empty?

@ceford
Copy link
Author

ceford commented May 22, 2024

What I am saying is that the Heading PermaLink Extension (https://commonmark.thephpleague.com/2.4/extensions/heading-permalinks/) creates an empty link before or after a heading as the destination of each item in the Contents and accessibility tools flag empty links as a serious error (https://webaim.org/techniques/hypertext/hypertext_links). The destination should not be a link at all and removing the href attribute from the destination tag seems to do just that. But is that the best way to do it?

@samwilson
Copy link

Ah, that makes sense. So you're saying that there are circumstances in which $fragmentPrefix and $slug are both empty strings and the result is just href="#"?

@ceford
Copy link
Author

ceford commented May 22, 2024

This is the code of a heading:

<h2>Introduction<a id="content-introduction" href="#content-introduction" class="heading-permalink" title="Permalink">¶</a></h2>

And this is the Contents item:

<li>
<a href="#content-introduction">Introduction</a>
</li>

It works fine but does not pass accessibility validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New functionality or behavior
Projects
None yet
Development

No branches or pull requests

2 participants