PrismJS / PrismJS/prism

Improving accessibility of highlighted code samples

Open
#1,284 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement plugins
Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

I’m at a Dagstuhl seminar about programming language usability and a researcher named Ameer Armaly (a screen reader user himself) presented an interesting technique he invented for making code skimmable by screen reader users by turning function & class declarations into headings (screen reader users can already jump to specific headings without having to read linearly). Do keep in mind that visually impaired users do not currently have any kind of syntax highlighting and have to read code linearly. This helps mitigate that.

It would be great if we could add this to Prism, at least as a plugin (since not all languages can utilize it). We could use aria-level="N" instead of actual heading elements, to avoid clashing with existing CSS for headings.

There are still some challenges to tackle before implementing. Ameer told me that JAWS doesn't deal well with aria-level="N" where N > 6. I don't know if that holds true for other screen readers, but if it does, that means we have to use small Ns, which could mess up the outline of the rest of the page. In theory that could be mitigated by wrapping the <pre> with a sectioning element, but those are not implemented either. :(

CCing @ljwatson who may be able to provide useful feedback.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named. Start by reviewing Prism's plugin architecture and the accessibility constraints described here, then determine whether the proposed heading approach can be specified and tested across supported screen readers; done requires an agreed implementation scope and accessibility behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.