All Projects → remarkjs → Remark Vdom

remarkjs / Remark Vdom

Licence: mit
plugin to compile Markdown to Virtual DOM

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Remark Vdom

vdom
Simple JavaScript Virtual DOM
Stars: ✭ 17 (-61.36%)
Mutual labels:  virtual-dom, vdom
Remark React
plugin to transform to React
Stars: ✭ 484 (+1000%)
Mutual labels:  markdown, virtual-dom
Refractor
Lightweight, robust, elegant virtual syntax highlighting using Prism
Stars: ✭ 291 (+561.36%)
Mutual labels:  virtual-dom, vdom
Mithril.js
A JavaScript Framework for Building Brilliant Applications
Stars: ✭ 13,062 (+29586.36%)
Mutual labels:  virtual-dom, vdom
Puddles
Tiny vdom app framework. Pure Redux. No boilerplate.
Stars: ✭ 24 (-45.45%)
Mutual labels:  virtual-dom, vdom
Asm Dom
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)
Stars: ✭ 2,604 (+5818.18%)
Mutual labels:  virtual-dom, vdom
Ivi
🔥 Javascript (TypeScript) library for building web user interfaces
Stars: ✭ 445 (+911.36%)
Mutual labels:  virtual-dom, vdom
Asm Dom Boilerplate
A simple boilerplate to start using asm-dom without configuration.
Stars: ✭ 49 (+11.36%)
Mutual labels:  virtual-dom, vdom
Backbone.vdomview
VirtualDOM-aware Backbone View
Stars: ✭ 23 (-47.73%)
Mutual labels:  virtual-dom, vdom
Domvm
DOM ViewModel - A thin, fast, dependency-free vdom view layer
Stars: ✭ 581 (+1220.45%)
Mutual labels:  virtual-dom, vdom
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (+311.36%)
Mutual labels:  virtual-dom, vdom
Preact
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Stars: ✭ 30,527 (+69279.55%)
Mutual labels:  virtual-dom, vdom
Omi
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架
Stars: ✭ 12,153 (+27520.45%)
Mutual labels:  virtual-dom, vdom
Ng Vdom
(Developer Preview) A virtual-DOM extension for Angular, also work as React bridge.
Stars: ✭ 249 (+465.91%)
Mutual labels:  virtual-dom, vdom
Neo
Create blazing fast multithreaded Web Apps
Stars: ✭ 1,219 (+2670.45%)
Mutual labels:  virtual-dom, vdom
Lowlight
Virtual syntax highlighting for virtual DOMs and non-HTML things
Stars: ✭ 310 (+604.55%)
Mutual labels:  virtual-dom, vdom
Vhtml
Render JSX/Hyperscript to HTML strings, without VDOM 🌈
Stars: ✭ 556 (+1163.64%)
Mutual labels:  virtual-dom, vdom
Muve
Muve is a micro library for building interactive javascript applications.
Stars: ✭ 11 (-75%)
Mutual labels:  virtual-dom, vdom
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-22.73%)
Mutual labels:  virtual-dom, vdom
Hyperx
🏷 - tagged template string virtual dom builder
Stars: ✭ 991 (+2152.27%)
Mutual labels:  virtual-dom

remark-vdom

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to compile Markdown to Virtual DOM.

  • [x] Inherently safe and sanitized: there is no way to pass raw HTML through
  • [x] Supports footnotes, todo lists
  • [x] Support VNode keys
  • [x] Custom components overwriting default elements (MyLink instead of <a>)

Note!

This plugin is ready for the new parser in remark (micromark, see remarkjs/remark#536). No change is needed: it works exactly the same now as it did before!

Install

npm:

npm install remark-vdom

Use

Say we have the following file, example.js:

var unified = require('unified')
var markdown = require('remark-parse')
var vdom = require('remark-vdom')

unified()
  .use(markdown)
  .use(vdom)
  .process('Some _emphasis_, **importance**, and `code`.', function(err, file) {
    if (err) throw err
    console.dir(file.result, {depth: null})
  })

Now, running node example yields:

VirtualNode {
  tagName: 'DIV',
  properties: { key: undefined },
  children: [
    VirtualNode {
      tagName: 'P',
      properties: { key: undefined },
      children: [
        VirtualText { text: 'Some ' },
        VirtualNode {
          tagName: 'EM',
          properties: { key: undefined },
          children: [ VirtualText { text: 'emphasis' } ],
          key: 'h-3',
          namespace: null,
          count: 1,
          hasWidgets: false,
          hasThunks: false,
          hooks: undefined,
          descendantHooks: false
        },
        VirtualText { text: ', ' },
        VirtualNode {
          tagName: 'STRONG',
          properties: { key: undefined },
          children: [ VirtualText { text: 'importance' } ],
          key: 'h-4',
          namespace: null,
          count: 1,
          hasWidgets: false,
          hasThunks: false,
          hooks: undefined,
          descendantHooks: false
        },
        VirtualText { text: ', and ' },
        VirtualNode {
          tagName: 'CODE',
          properties: { key: undefined },
          children: [ VirtualText { text: 'code' } ],
          key: 'h-5',
          namespace: null,
          count: 1,
          hasWidgets: false,
          hasThunks: false,
          hooks: undefined,
          descendantHooks: false
        },
        VirtualText { text: '.' }
      ],
      key: 'h-2',
      namespace: null,
      count: 10,
      hasWidgets: false,
      hasThunks: false,
      hooks: undefined,
      descendantHooks: false
    }
  ],
  key: 'h-1',
  namespace: null,
  count: 11,
  hasWidgets: false,
  hasThunks: false,
  hooks: undefined,
  descendantHooks: false
}

API

remark().use(vdom[, options])

Compile Markdown to Virtual DOM.

ℹ️ In [email protected], the result of .process changed from file.contents to file.result.

options
options.sanitize

How to sanitize the output (Object or boolean, default: null).

Sanitation is done by hast-util-sanitize, except when false is given. If an object is passed in, it’s given as a schema to sanitize. By default, input is sanitized according to GitHub’s sanitation rules.

Embedded HTML is always stripped.

For example, by default classNames are stripped. To keep them in, use something like:

var merge = require('deepmerge')
var gh = require('hast-util-sanitize/lib/github')

var schema = merge(gh, {attributes: {'*': ['className']}})

var vtree = remark()
  .use(vdom, {sanitize: schema})
  .processSync(/* ... */)
options.prefix

Optimization hint (string, default: h-).

options.h

Hyperscript to use (Function, default: require('virtual-dom/h')).

options.components

Map of tag names to custom components (Object.<Function>, optional). That component is invoked with tagName, props, and children. It can return any VDOM compatible value (such as VNode, VText, Widget). For example:

var components = {code: code}

function code(tagName, props, children) {
  // Ensure a default programming language is set.
  if (!props.className) {
    props.className = 'language-js'
  }

  return h(tagName, props, children)
}

Integrations

Integrates with the same tools as remark-html.

Security

Use of remark-vdom is safe by default, but changing the sanitize option can open you up to a cross-site scripting (XSS) attack if the tree is unsafe.

Related

Contribute

See contributing.md in remarkjs/.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, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

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].