Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Introduce ano-empty-alt-text rule#85

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
khiga8 merged 22 commits intomainfromkh-enforce-alt-is-always-set
Oct 9, 2023
Merged

Conversation

khiga8
Copy link
Contributor

@khiga8khiga8 commentedOct 6, 2023
edited
Loading

This PR introduces a new rule,no-empty-alt-text which nudges people to add alt text when they set an image to decorative. Settingalt="" to mark decorative images is usually acceptable, but currently leads to unexpected behaviors, specifically on GitHub.

There is currently a known issue on GitHub where all images are rendered inside of an anchor tag. As a result of this, decorative images result in links without an accessible name. Therefore, it's a good idea to always set alt text on markdown images on GitHub. However, this rule isn't really a long term solution and this issue is best fixed in GitHub in the long-term.

⚠️ This rule is SPECIFIC to GitHub's UI markdown behavior and is OFF by default since it's building on top of unideal behavior.

This rule should be removed in the future when we stops wrapping images in anchor tags.

We plan to enable this ingithub/accessibility-alt-text-bot#33.

@khiga8khiga8 marked this pull request as ready for reviewOctober 6, 2023 14:10
@khiga8khiga8 requested a review froma team as acode ownerOctober 6, 2023 14:10
### Incorrect 👎

```md
![""](cat.png)
Copy link
Member

@iansan5653iansan5653Oct 6, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not sure about this example. The alt text in the Markdown form is never quoted like an HTML property, so this would result in an image tag like<img alt='""' src="cat.png" />. While an alt text of"" is not useful, it's not empty either. The only way to create a truly empty alt tag in Markdown is with the HTML formalt="", so maybe we should only focus on HTML for this rule.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think auseful-alt-text rule might be an interesting avenue to explore, where we ban things like "screenshot", "image", "example", '""', etc. But I think that's a separate rule from empty text.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah! You're right -- thank you for catching that! I'll stick with HTML for this rule!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

useful-alt-text

Theno-default-alt-text currently flags alternative text like,image,Image,Screen Shot 2022-06-26 at 7 41 30 PM though it's not comprehensive by any means. We could potentially expand on that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, I think we definitely could expand on that! It might be interesting to see if we can run a query to figure out what the most common alt texts are across GitHub -- I bet the top 20 or so are all things we'd probably want to lint against.

khiga8 reacted with heart emoji
Comment on lines 19 to 23
const inlineImages = params.parsers.markdownit.tokens.filter(
(token) =>
token.type === "inline" &&
token.children.some((child) => child.type === "image"),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Per other comment - we probably should limit this rule to just HTML tags

khiga8 reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Removed markdown syntax in00fc5dd!

expect(results).toHaveLength(0);
});
});
describe("failures", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not super important, but it might also be useful to have a test for two failures in one line, like:

<imgsrc="cat.png"alt="" /> <imgsrc="dog.png"alt="" />

I think we do handle this correctly with theg flag and iterating over matches per line, but it probably would still be good to test it.

khiga8 reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good idea! Done in8f80d4d.

rules: [
require("./no-default-alt-text"),
require("./no-generic-link-text"),
require("./no-empty-string-alt"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🤔 Maybe we should call this oneno-empty-alt orno-empty-alt-text?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I likeno-empty-alt-text!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Renamed inf2d9774.

@khiga8khiga8 marked this pull request as draftOctober 6, 2023 16:17
@khiga8khiga8 changed the titleIntroduce ano-empty-string-alt ruleIntroduce ano-empty-alt-text ruleOct 6, 2023
@khiga8khiga8 marked this pull request as ready for reviewOctober 6, 2023 21:08
Copy link
Contributor

@kendallgassnerkendallgassner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should we export a preset for GitHub markdown?

khiga8 reacted with eyes emoji
Base automatically changed fromkh-add-more-coverge tomainOctober 9, 2023 14:55
khiga8and others added2 commitsOctober 9, 2023 11:02
Co-authored-by: Ian Sanders <iansan5653@github.com>
Co-authored-by: Ian Sanders <iansan5653@github.com>
@khiga8
Copy link
ContributorAuthor

Should we export a preset for GitHub markdown?

discussing over Slack!

@khiga8khiga8 merged commitccc7d23 intomainOct 9, 2023
@khiga8khiga8 deleted the kh-enforce-alt-is-always-set branchOctober 9, 2023 15:04
@janbrasnajanbrasna mentioned this pull requestFeb 25, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iansan5653iansan5653iansan5653 approved these changes

@kendallgassnerkendallgassnerkendallgassner approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@khiga8@iansan5653@kendallgassner

[8]ページ先頭

©2009-2025 Movatter.jp