Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

HTML processor to parse and compile with browser APIs, powered by plugins

License

NotificationsYou must be signed in to change notification settings

rehypejs/rehype-dom

Repository files navigation

BuildCoverageDownloadsSizeSponsorsBackersChat

This project is a monorepo that contains alternatives torehype for use inbrowsers.

Contents

What is this?

This monorepo contains the following packages:

  • rehype-dom-parse— plugin to take HTML as input and turn it into a syntax tree (hast) inbrowsers
  • rehype-dom-stringify— plugin to take a syntax tree (hast) and turn it into HTML as output inbrowsers
  • rehype-domunified,rehype-dom-parse, andrehype-dom-stringify, useful wheninput and output are HTML

When should I use this?

You can use this project when you want to use rehype in browsers.It has a smaller footprint in browsers compared torehype itself as it usesDOM APIs to do its work.However, DOM APIs:

  • …cannot provide positional information (each node knowing where itoriginated), which is frequently needed when working with rehype
  • …do not have formatting options thatrehype-stringify exposes
  • …can provide varying results in different (especially older) browsers
  • …are safe, but untrusted HTML in browsers is always unsafe

Example

Say our pageexample.html looks as follows:

<!doctype html><title>Example</title><body><scripttype="module">import{rehypeDom}from'https://esm.sh/rehype-dom@7?bundle'constfile=awaitrehypeDom().process('<h1>Hi <del>Mars</del>Venus!</h1>')document.body.innerHTML=String(file)</script>

Now runningopen example.html renders the following in<body>:

<h1>Hi<del>Mars</del>Venus!</h1>

Security

Use ofrehype-dom can open you up to across-site scripting (XSS)attack if dangerous content is used and the result is used with the actual DOM.Userehype-sanitize to solve that.

Contribute

Seecontributing.md inrehypejs/.github for waysto get started.Seesupport.md for ways to get help.

This project has acode of conduct.By interacting with this repository, organisation, or community you agree toabide by its terms.

License

ISC ©Keith McKnight


[8]ページ先頭

©2009-2025 Movatter.jp