npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

rehype-github-notranslate

v1.0.0

Published

rehype plugin to enhance raw text with `notranslate`

Downloads

15

Readme

rehype-github-notranslate

Build Coverage Downloads Size Sponsors Backers Chat

rehype plugin to enhance raw text with notranslate.

Contents

What is this?

This plugin enhances raw text by adding a mark to them that tells tools like Google Translate to not translate them. By default it adds class="notranslate" to pre and code.

This behavior is specific to github.com that only work in comments, not in files.

This plugin is part of a monorepo rehype-github. See its readme for more info.

When should I use this?

You can use this plugin when you want to match how github.com works or when you want to build similar pipelines that have user content.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install rehype-github-notranslate

In Deno with esm.sh:

import rehypeGithubNoTranslate from 'https://esm.sh/rehype-github-notranslate@1'

In browsers with esm.sh:

<script type="module">
  import rehypeGithubNoTranslate from 'https://esm.sh/rehype-github-notranslate@1?bundle'
</script>

Use

Say our module example.js looks as follows:

import rehypeGithubNoTranslate from 'rehype-github-notranslate'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import {unified} from 'unified'

const file = await unified()
  .use(rehypeParse, {fragment: true})
  .use(rehypeGithubNoTranslate)
  .use(rehypeStringify)
  .process('<code>xxx</code>')

console.log(String(file))

…now running node example.js yields:

<code class="notranslate">xxx</code>

API

This package exports the identifier defaultInclude. The default export is rehypeGithubNoTranslate.

defaultInclude

List of tag names that github.com enhances (Array<string>).

rehypeGithubNoTranslate(options?)

Plugin to enhance raw text with notranslate.

Parameters
  • options (Options, optional) — configuration

Options

Configuration (TypeScript type).

Fields
  • include (Array<string>, default: defaultInclude) — elements to enhance; the default behavior is to add notranslate to code and pre

Bugs

There are no particular bugs with how this work, other than that they could do this on files too, and that they should perhaps use ['code', 'kbd', 'pre', 'tt'] instead. Furthermore, there are cases where you would want code to be translated, that automation can’t solve.

Authoring

There are no additional recommendations on how to author links in markdown.

HTML

The markup for that github.com adds is:

class="notranslate"

CSS

No CSS is needed.

Syntax

No syntax is applicable.

Types

This package is fully typed with TypeScript. It exports the additional type Options.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 16+. Our projects sometimes work with older versions, but this is not guaranteed.

This plugin works with rehype-parse version 3+, rehype-stringify version 3+, rehype version 5+, and unified version 6+.

Security

This package is safe.

Related

Contribute

See contributing.md in rehypejs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

Notice

This project is not affiliated with GitHub.

License

MIT © Titus Wormer