rehype-accessible-emojis
Written in Typescript
As I couldn't get gatsby-remark-a11y-emoji working with gatsby-plugin-mdx I made this rehype version to make emojis accessible by wrapping them in a <span role="image">
with aria-label
set to the emojis description based on gemoji.
So
😅
turns into
😅
so screenreaders and other assistive technology can understand the emojis and act accordingly by for example reading the aria-label
.
Install
yarn add -D rehype-accessible-emojis# or npm i -D rehype-accessible-emojis
Usage
Using Rehype
Given an example.html
like
Hello World! 👋 Hi, I love emojis a lot 🤓
and example.js
like
running node example
results in
Hello World! 👋 Hi, I love emojis a lot 🤓
Using gatsby-plugin-mdx
// gatsby-config.js resolve: `gatsby-plugin-mdx` options: rehypePlugins: rehypeAccessibleEmojis
Options
options.ignore
(Array, default: ['title', 'script', 'style', 'svg', 'math']
)
Tag-names of parents to ignore, to not wrap an emoji within a <script>
for example.
Will be merged with the defaults.