All Projects → rehypejs → rehype-dom

rehypejs / rehype-dom

Licence: ISC license
HTML processor to parse and compile with browser APIs, powered by plugins

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rehype-dom

rehype-highlight
plugin to highlight code blocks
Stars: ✭ 127 (+535%)
Mutual labels:  rehype, rehype-plugin
redot
Graphviz dot file processor powered by plugins based on @unifiedjs
Stars: ✭ 60 (+200%)
Mutual labels:  ast, unified
rehype-autolink-headings
plugin to add links to headings in HTML
Stars: ✭ 50 (+150%)
Mutual labels:  rehype, rehype-plugin
rehype-raw
plugin to parse the tree again
Stars: ✭ 61 (+205%)
Mutual labels:  rehype, rehype-plugin
html5parser
A super tiny and fast html5 AST parser.
Stars: ✭ 153 (+665%)
Mutual labels:  dom, ast
react-remark
React component and hook to use remark to render markdown
Stars: ✭ 81 (+305%)
Mutual labels:  unified, rehype
gram-js
Gram in javascript.
Stars: ✭ 21 (+5%)
Mutual labels:  ast, unified
Remark
remark is a popular tool that transforms markdown with plugins. These plugins can inspect and change your markup. You can use remark on the server, the client, CLIs, deno, etc.
Stars: ✭ 4,746 (+23630%)
Mutual labels:  ast, unified
Rehype
HTML processor powered by plugins part of the @unifiedjs collective
Stars: ✭ 634 (+3070%)
Mutual labels:  ast, unified
Orgajs
parse org-mode content into AST
Stars: ✭ 417 (+1985%)
Mutual labels:  ast, unified
Retext
natural language processor powered by plugins part of the @unifiedjs collective
Stars: ✭ 2,119 (+10495%)
Mutual labels:  ast, unified
Micromark
the smallest commonmark compliant markdown parser that exists; new basis for @unifiedjs (hundreds of projects w/ billions of downloads for dealing w/ content)
Stars: ✭ 793 (+3865%)
Mutual labels:  ast, unified
Nativejsx
JSX to native DOM API transpilation. 💛 <div> ⟹ document.createElement('div')!
Stars: ✭ 145 (+625%)
Mutual labels:  dom, ast
InDiv
an angular like web mvvm framework.一个类 angular 前端框架。https://dimalilongji.github.io/InDiv
Stars: ✭ 88 (+340%)
Mutual labels:  dom
bs-declaredom
Strongly typed declarative markup for the DOM and CSS
Stars: ✭ 66 (+230%)
Mutual labels:  dom
Web-Map-Custom-Element
A custom <mapml-viewer> and <layer-> element suite
Stars: ✭ 49 (+145%)
Mutual labels:  dom
hast-util-from-dom
utility to transform a DOM tree to hast
Stars: ✭ 20 (+0%)
Mutual labels:  dom
gox
JSX for Go
Stars: ✭ 165 (+725%)
Mutual labels:  ast
java-ast
Java Parser for JavaScript/TypeScript (based on antlr4ts)
Stars: ✭ 58 (+190%)
Mutual labels:  ast
string-dom
Create HTML strings using JSX (or functions).
Stars: ✭ 13 (-35%)
Mutual labels:  dom

rehype-dom

Build Coverage Downloads Size Sponsors Backers Chat

This project is a monorepo that contains alternatives to rehype for use in browsers.

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) in browsers
  • rehype-dom-stringify — plugin to take a syntax tree (hast) and turn it into HTML as output in browsers
  • rehype-domunified, rehype-dom-parse, and rehype-dom-stringify, useful when input 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 to rehype itself as it uses DOM APIs to do its work. However, DOM APIs:

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

Example

Say our page example.html looks as follows:

<!doctype html>
<title>Example</title>
<body>
<script type="module">
  import {rehypeDom} from 'https://esm.sh/rehype-dom@6?bundle'

  const file = await rehypeDom().process('<h1>Hi <del>Mars</del>Venus!</h1>')

  document.body.innerHTML = String(file)
</script>

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

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

Security

Use of rehype-dom can open you up to a cross-site scripting (XSS) attack if the document is unsafe or unsafe plugins are used. Use rehype-sanitize to make the tree safe.

Contribute

See contributing.md in rehypejs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

ISC © Keith McKnight

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].