Code Monkey home page Code Monkey logo

remark-a11y-emoji's Introduction

remark-a11y-emoji

Unit tests

Plugin for Remark to make emoji accessible. This plugin wraps emoji in a <span> and sets the name of the emoji as aria-label. For example, the input inline ๐ŸŽ‰ emoji becomes:

inline <span role="img" aria-label="party popper">๐ŸŽ‰</span> emoji

remark-a11y-emoji also works with Gatsby.

Made by ๐Ÿ‘จโ€๐Ÿ’ปFlorian Eckerstorfer in beautiful ๐ŸŽก Vienna, Europe.

Table of Contents

  1. Installation
  2. Configuration
  3. Configuration with Gatsby
  4. Code of Conduct
  5. Contributing
  6. License
  7. Change-log

Installation

You need to install @fec/remark-a11y-emoji with NPM or Yarn. Since this is a plugin for Remark, I assume you already have Remark installed and configured.

npm install -D @fec/remark-a11y-emoji
yarn add --dev @fec/remark-a11y-emoji

Configuration

You can use @fec/remark-a11y-emoji like any other Remark plugin. The plugin produces an AST (hast, rehype), which you can serialize to HTML with rehype-stringify:

import remark from 'remark';
import a11yEmoji from '@fec/remark-a11y-emoji';
import rehypeStringify from 'rehype-stringify';
import remarkRehype from 'remark-rehype';

const processor = remark()
  .use(a11yEmoji)
  .use(remarkRehype)
  .use(rehypeStringify);

Configuration with Gatsby

module.exports = {
  // ...
  plugins: [
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          // ...
          '@fec/remark-a11y-emoji/gatsby',
        ],
      },
    },
  ],
};

Code of Conduct

See CODE_OF_CONDUCT

Contributing

To contribute to @fec/remark-a11y-emoji, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Install dependencies: npm install
  4. Make your changes (and don't forget to update the tests)
  5. Don't forgot to run the tests: npm test
  6. Commit your changes: git commit -m '<commit_message>'
  7. Push to the original branch: git push origin <project_name>/<location>
  8. Create the pull request.

Alternatively see the GitHub documentation on creating a pull request.

License

See LICENSE

Change log

See CHANGELOG

remark-a11y-emoji's People

Contributors

amirahaile avatar dependabot-preview[bot] avatar dependabot[bot] avatar florianeckerstorfer avatar jameshfisher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

remark-a11y-emoji's Issues

Text with inline emoji is wrapped in <undefined>

When I use this plugin on a paragraph that contains emoji, the output is wrapped in <undefined> tags.

Example:

A line of text with ๐Ÿ˜€ inline ๐ŸŽ‰ emoji

Rendered HTML:

<p>
  <undefined>
    A line of text with <span role="img" aria-label="grinning face">๐Ÿ˜€</span> inline <span role="img" aria-label="party popper">๐ŸŽ‰</span> emoji
  </undefined>
</p>

However, emoji on a line of their own are not wrapped in those undefined tags:

๐Ÿ‘
<p>
  <span role="img" aria-label="thumbs up">๐Ÿ‘</span>
</p>

Context:

  • Next.js 9.4.4
  • next-mdx-enhanced 3.0.0
  • @fec/remark-a11y-emoji 1.0.0

How does this plugin improve accessibility ?

Hello,

I would like to know how does that plugin is adding anything to the UX of users using assistive technologies?

I always believed that aria-label should be used on icons (or icon-like images as small SVG). But emojis are not just plain images and should already have a description based on the Unicode description and CLDR name (which are in english but should be translated to user language I guess).

I'm don't understand so why this plugin is necessary.

I'm pretty sure, there is a good explanation of why this plugin is necessary and maybe this explanation should be in the README.md of the project for people like me who don't have a good enough accessibility background.

Thank you!

`aria-label` for new emojis not displayed due to outdated dependency

Hi maintainer,

When new emojis such as ๐Ÿซก or ๐Ÿซจ are used, it seems that the output would not contain the proper aria-label for them. Investigating further, it seems to be because the dependent package gemoji (with version specifier "^6.1.0") is outdated. The latest version as of this writing is 8.1.0.

Would it be possible for you to update the version of such package? Alternatively, if possible at all, would it be possible to make gemoji a peer dependency.

Thanks for your work!

remark@next (13)

Hi!

remark is switching to a new parser internally (micromark, see remarkjs/remark#536 for more info).
From a quick glance at the code, it seems this plugin should be fine. However, it would be good to check that in the future (there is 13.0.0-alpha.0 published now, and one or two more will come before the release)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.