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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@saeris/remark-ayaji

v1.1.0

Published

Remark plugin that performs Japanese Grammar syntax highlighting in code fences.

Readme

🌈 remark-ayaji Build Status npm

「あや・じ」: colorful letters

A remark plugin to add "syntax-highlighting" for Japanese grammar as a code fence language. It uses kuromoji to tokenize Japanese text into it's component parts of speech.

📦 Installation

[!Note]

This library is distributed only as an ESM module.

npm install @saeris/remark-ayaji

or

yarn add @saeris/remark-ayaji

🔧 Usage

Using this library will depend on your particular application or framework. Below is a bare-bones example to test it in Node.

Node:

import remark from "remark";
import remarkParse from "remark-parse";
import remarkAyaji from "@saeris/remark-ayaji";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";

const result = await remark()
  .use(remarkParse)
  .use(remarkAyaji, { dict: `path/to/dictionaries/directory/` })
  .use(remarkRehype)
  .use(rehypeStringify)
  .process(markdown);

console.log(result.tostring());

CSS:

This library also distributes an optional CSS file to get you started with syntax highlighting. Consuming it will largely depend on your particular application's conventions. In frameworks such as Nextjs or Astro, importing the file in your root layout should be all you need.

import "@saeris/remark-ayaji/theme.css";

🖋️ Syntax

Highlighting works in a similar manner to syntax highlighters for code, using code fences with a jp language annotation:

```jp
日本語が分かります。
```

This will compile to the following HTML:

<p><span class="noun">日本語</span><span class="particle">が</span><span class="verb">分かり</span><span class="auxiliary-verb"ます</span>。</p>

🎛️ Options

type PoS =
  | "prefix"
  | "pronoun"
  | "adnominal"
  | "noun"
  | "adjectival-noun"
  | "adjective"
  | "particle"
  | "conjunction"
  | "interjection"
  | "adverb"
  | "verb"
  | "auxiliary-verb";

interface Options {
  dict: string;
  furigana?: boolean;
  include?: PoS[];
  exclude?: PoS[];
}

This plugin can be configured both globally via an options object supplied alongside where the plugin is imported and used, or locally via the code fence meta after the language attribute in a comma-separated, JSON-like syntax. Examples can be found below.

options.dict (Required, Global Only)

This plugin relies on various dictionary files for the tokenizer to work. While kuromoji includes these files, they cannot automatically be loaded and must be done so manually. Depending on your environment, you may need to copy the dict directory of @saeris/kuromoji to somewhere in your project. For example, if it exists in your project root, you can configure the plugin like this:

// ...
.use(remarkAyaji, { dict: path.join(process.cwd(), `./dict`) })
// ...

These dictionary files are from the mecab project, please see NOTICE for license details.

options.furigana

Adds furigana to words containing kanji in the Denden Furigana markdown syntax: {日本語|にほんご}. By combining this plugin with remark-denden-ruby, this will produce <ruby> text annotations to further aid in readability.

global config:

// ...
.use(remarkAyaji, { dict, furigana: true })
.use(remarkRuby) // plugin order is important!
// ...

local config:

```jp furigana: true
日本語
```

result:

<p>
  <span class="noun"
    ><ruby>日本語<rp>(</rp><rt>にほんご</rt><rp>)</rp></ruby></span
  >
</p>

[!Warning]

Because of the nature of morphological analysis, which is the means by which kuromoji handles tokenization, the best match for the reading of any particular kanji or word containing kanji will be based on the most common usage of that kanji. This means that certain words, most often proper nouns like names, will have a false-positive reading match.

options.include

An array of parts of speech to include in highlighting.

global config:

.use(remarkAyaji, { include: ["noun"] })
.use(remarkRuby) // plugin order is important!

local config:

```jp include: ["noun"]
日本語が分かります。
```

result:

<p><span class="noun">日本語</span>が分かります。</p>

options.exclude

An array of parts of speech to exclude in highlighting. This will take precidence over any parts of speech specified in include regardless of whether it is enabled globally or locally.

global config:

.use(remarkAyaji, { exclude: ["noun", "auxiliary-verb"] })
.use(remarkRuby) // plugin order is important!

local config:

```jp exclude: ["noun", "auxiliary-verb"]
日本語が分かります。
```

result:

<p>日本語<span class="particle">が</span><span class="verb">分かり</span>ます。</p>

🥂 License

Released under the MIT © Drake Costa