Giter Club home page Giter Club logo

rehype-ignore's Introduction

rehype-ignore

Buy me a coffee Downloads NPM version Build Coverage Status Repo Dependents

Ignore content display via HTML comments, Shown in GitHub readme, excluded in HTML.

Installation

This package is ESM only: Node 12+ is needed to use it and it must be import instead of require.

npm install rehype-ignore

Options

export declare type RehypeIgnoreOptions = {
  /**
   *  Character to use for opening delimiter, by default `rehype:ignore:start`
   */
  openDelimiter?: string;
  /**
   * Character to use for closing delimiter, by default `rehype:ignore:end`
   */
  closeDelimiter?: string;
};

Usage

import { rehype } from 'rehype';
import rehypeIgnore from 'rehype-ignore';

rehype()
  .data('settings', { fragment: true })
  .use(rehypeIgnore, { })

HTML Example

<h1>header</h1>
<p>
  Hello <!--rehype:ignore:start--> <code>World</code> <!--rehype:ignore:end-->
</p>

Output:

<h1>header</h1>
<p>
  Hello </p>
import { rehype } from 'rehype';
import rehypeIgnore from 'rehype-ignore';

const html = `<h1>header</h1>
<p>
  Hello <!--rehype:ignore:start--> <code>World</code> <!--rehype:ignore:end-->
</p>`

const htmlStr = rehype()
  .data('settings', { fragment: true })
  .use(rehypeAttrs, { properties: 'attr' })
  .processSync(html)
  .toString()

Markdown Example

# Hello World

<!--rehype:ignore:start-->Hello World<!--rehype:ignore:end-->

Good!

Output:

<h1>Hello World</h1>

<p>Good!</p>
import { unified } from 'unified';
import rehypeIgnore from 'rehype-ignore';
import remarkParse from 'remark-parse';
import remark2rehype from 'remark-rehype';
import rehypeRaw from 'rehype-raw';
import stringify from 'rehype-stringify';

const html = `# Hello World

<!--rehype:ignore:start-->Hello World<!--rehype:ignore:end-->

Good!`

const htmlStr = unified()
  .use(remarkParse)
  .use(remark2rehype, { allowDangerousHtml: true })
  .use(rehypeRaw)
  .use(rehypeIgnore, { })
  .use(stringify)
  .processSync(html)
  .toString()

Related

Contributors

As always, thanks to our amazing contributors!

Made with action-contributors.

License

MIT © Kenny Wong

rehype-ignore's People

Contributors

jaywcjlove avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

rehype-ignore's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v3
  • ncipollo/release-action v1
.github/workflows/pull_request.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • unified ^11.0.0
  • unist-util-visit ^5.0.0
  • hast-util-select ^6.0.0
  • rehype ^13.0.0
  • rehype-stringify ^10.0.0
  • rehype-raw ^7.0.0
  • remark-parse ^11.0.0
  • remark-rehype ^11.0.0
  • tsbb ^4.2.3
  • node >=16

  • Check this box to trigger a request for Renovate to run again on this repository

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.