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

remark-disable-text-escape

v1.7.0

Published

A Remark plugin to prevent special characters from being escaped by remark-stringify

Downloads

759

Readme

remark-disable-text-escape

npm version npm downloads license

A remark plugin to prevent special characters from being escaped by remark-stringify.

Problem

By default, remark-stringify escapes special characters in text nodes (e.g., [\[, *\*, _\_, (\(, @\@) to avoid ambiguity with Markdown syntax. This can be undesirable when you want to preserve these characters as-is in your Markdown output (e.g., **強調** becoming \*\*強調\*\* or foo_bar_baz becoming foo\_bar\_baz).

Additionally:

  • Parentheses and ampersands in link/image URLs are escaped (e.g., [text](url(x))[text](url\(x\)), [text](a&b)[text](a\&b))
  • Autolinks containing special characters lose their format (e.g., <http://a_b.com>[http://a_b.com](http://a_b.com))
  • When used with remark-wiki-link, underscores in WikiLinks are escaped (e.g., [[page_name]][[page\_name]])

How it works

This plugin works in three ways:

  1. Custom Node Pattern — transforms special characters in text nodes into custom literalChar AST nodes with a dedicated serialization handler. Since mdast-util-to-markdown only escapes characters inside text nodes, moving them into a custom node bypasses the escaping logic entirely.

  2. Custom link/image handlers — overrides the default link and image handlers to correctly detect autolinks even after tree transformation, and to use angle bracket syntax (<url>) for URLs containing parentheses to avoid escaping.

  3. Custom wikiLink handler — overrides the remark-wiki-link handler to output values directly without escaping.

Install

This package is ESM only. Node.js 16+ is required.

npm install remark-disable-text-escape

Usage

import { remark } from "remark";
import remarkDisableTextEscape from "remark-disable-text-escape";

const result = await remark()
  .use(remarkDisableTextEscape)
  .process("some text with [brackets] and foo_bar_baz");

console.log(String(result));
// => "some text with [brackets] and foo_bar_baz\n"

Autolinks with special characters are preserved:

const result2 = await remark()
  .use(remarkDisableTextEscape)
  .process("<http://a_b.com>");

console.log(String(result2));
// => "<http://a_b.com>\n"

Parentheses in link URLs are not escaped:

const result3 = await remark()
  .use(remarkDisableTextEscape)
  .process("[text](url(x))");

console.log(String(result3));
// => "[text](<url(x)>)\n"

With remark-wiki-link

import remarkWikiLink from "remark-wiki-link";

const result4 = await remark()
  .use(remarkWikiLink, { aliasDivider: "|" })
  .use(remarkDisableTextEscape, { aliasDivider: "|" })
  .process("[[page_name]]");

console.log(String(result4));
// => "[[page_name]]\n"

API

remarkDisableTextEscape(options?)

Plugin to disable escaping of special characters.

All special characters ([, ], (, ), *, _, &, |, ~, !, @) in text nodes will be preserved as-is in the output. Autolink format is preserved, and parentheses/ampersands/at-signs in link/image URLs are not escaped.

options.aliasDivider

Type: string Default: "|"

The alias divider used by remark-wiki-link. Set this to the same value as the aliasDivider option in your remark-wiki-link configuration.

Types

This package is written in TypeScript and ships with type definitions. It exports the LiteralChar and RemarkDisableTextEscapeOptions types.

import type {
  LiteralChar,
  RemarkDisableTextEscapeOptions,
} from "remark-disable-text-escape";

Compatibility

  • Node.js 16+
  • remark-stringify ^11.0.0 (peer dependency)
  • remark-wiki-link ^2.0.0 (optional — wikiLink handler is only active when this plugin is used)
  • ESM only — cannot be require()'d

Caveats

This plugin disables escaping of special characters ([, ], (, ), *, _, &, |, ~, !, @) in all text nodes, and prevents escaping of parentheses, ampersands, and at-signs in link/image URLs. If the output Markdown is later re-parsed, unescaped characters may be interpreted as Markdown syntax, changing the document semantics. Use this plugin only when you control the final output and do not expect round-trip fidelity.

License

MIT