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

@pho9ubenaa/remark-mask-text-beta

v0.0.11

Published

A remark plugin to mask text content with block characters

Downloads

22

Readme

remark-mask-text-beta

[!IMPORTANT] This is an experimental package.

npm version License: MIT TypeScript

A powerful and flexible remark plugin that masks text content within specified delimiters, perfect for protecting sensitive information or creating educational materials where answers need to be hidden.

✨ Features

  • 🛡️ Privacy Protection: Mask sensitive information in markdown documents

  • 📚 Educational Tools: Hide answers in educational materials

  • ⚙️ Highly Configurable: Custom delimiters and mask characters

  • 🚀 Performance Optimized: Processes 10k+ lines in under 1 second

  • 🌍 Unicode Support: Full Unicode and emoji support

  • 🔧 TypeScript Ready: Written in TypeScript with full type definitions

  • 📦 Zero Dependencies: Lightweight with minimal footprint

  • 🧪 Thoroughly Tested: >95% test coverage with comprehensive edge case handling

  • 📝 TypeScript: Full type safety with comprehensive JSDoc documentation

  • 🧪 Well Tested: Comprehensive test suite with >95% coverage

Installation

npm install remark-mask-text

Usage

Basic Usage

import { remark } from 'remark';
import { remarkMaskText } from 'remark-mask-text';

const processor = remark().use(remarkMaskText);

const input = 'This document contains ::confidential:: information.';
const result = processor.processSync(input);

console.log(result.toString());
// Output: "This document contains ############# information."

Custom Configuration

import { remark } from 'remark';
import { remarkMaskText } from 'remark-mask-text';

const processor = remark().use(remarkMaskText, {
  maskCharacter: '*',    // Use asterisks instead of hash symbols
  maskDelimiter: '||'    // Use || instead of :: as delimiters
});

const input = 'Hide ||secret data|| with custom masks.';
const result = processor.processSync(input);

console.log(result.toString());
// Output: "Hide *********** with custom masks."

API

remarkMaskText(options?)

The main plugin function that creates a remark transformer.

Parameters

  • options (optional): Configuration object

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | maskCharacter | string | '#' | Character used to replace masked content | | maskDelimiter | string | '::' | Delimiter pattern marking text to be masked |

Returns

A remark transformer function that processes the AST to mask specified text regions.

Examples

Privacy Protection

# Internal Document

This report contains ::classified information:: that should not be visible.

Financial data: ::$1,234,567:: in revenue.

Output:

# Internal Document

This report contains ################### that should not be visible.

Financial data: ######### in revenue.

Educational Materials

# Quiz

What is the capital of France? ::Paris::

Complete the equation: 2 + 2 = ::4::

Output:

# Quiz

What is the capital of France? #####

Complete the equation: 2 + 2 = #

Multiple Mask Regions

The password is ::secret123:: and the username is ::admin::.

Output:

The password is ######### and the username is ####.

Custom Delimiters

// Using custom delimiters for specific contexts
const processor = remark().use(remarkMaskText, {
  maskDelimiter: '{{hidden}}'
});

// Input: "Data: {{hidden}}sensitive info{{hidden}} here."
// Output: "Data: ############## here."

Technical Details

How It Works

  1. AST Traversal: The plugin recursively traverses the remark AST (Abstract Syntax Tree)
  2. Pattern Matching: Identifies text nodes containing the specified delimiter pattern
  3. Region Extraction: Uses regex to find all masked regions within text nodes
  4. Node Transformation: Replaces masked content with HTML nodes containing mask characters
  5. Length Preservation: Each character in the original content is replaced with one mask character

Performance

  • Time Complexity: O(n) where n is the document length
  • Space Complexity: O(m) where m is the number of mask regions
  • Benchmark: Processes 10,000 lines with 1,000 mask regions in <1 second

Character Support

  • Unicode Safe: Properly handles multi-byte Unicode characters
  • Length Accurate: Mask length matches original content character count
  • Encoding Agnostic: Works with any valid UTF-8 content

Integration Examples

With MDX

import { compile } from '@mdx-js/mdx';
import { remarkMaskText } from 'remark-mask-text';

const mdxContent = `
# Secure Document
This contains ::sensitive data:: information.
`;

const compiled = await compile(mdxContent, {
  remarkPlugins: [remarkMaskText]
});

With Docusaurus

// docusaurus.config.js
module.exports = {
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          remarkPlugins: [
            ['remark-mask-text', { maskCharacter: '█' }]
          ],
        },
      },
    ],
  ],
};

With Gatsby

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-mdx',
      options: {
        remarkPlugins: [
          ['remark-mask-text', { 
            maskDelimiter: '%%',
            maskCharacter: '*'
          }]
        ],
      },
    },
  ],
};

Edge Cases

Empty Mask Regions

Empty mask: ::::

Output:

Empty mask: 

Unclosed Delimiters

Unclosed :: delimiter

Output:

Unclosed :: delimiter

(No transformation occurs)

Nested Content

The plugin processes the outermost delimiter pairs first:

::outer ::inner:: content::

Output:

######################

TypeScript Support

This package includes comprehensive TypeScript definitions:

import type { RemarkMaskTextOptions } from 'remark-mask-text';

const options: RemarkMaskTextOptions = {
  maskCharacter: '█',
  maskDelimiter: '||'
};

License

MIT © pHo9UBenaA