New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remark-vdom

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-vdom

Compile Markdown to VDOM with remark

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2K
increased by57.04%
Maintainers
1
Weekly downloads
 
Created
Source

remark-vdom Build Status Coverage Status

remark-vdom compiles markdown to Virtual DOM. Built on remark, an extensively tested and pluggable markdown parser.

  • Inherently safe and sanitized: there is no way to pass raw HTML through.

  • Supports footnotes, todo lists;

  • Future: support VNode keys.

  • Future: allow custom components to overwrite default elements, e.g., MyLink instead of <a>.

  • Future: Expose as widget

Note: remark-vdom exposes an array of VNodes. You will probably need to wrap the result in, for example, an article node, for rendering by virtual-dom.

Installation

npm:

npm install remark-vdom

remark-vdom is also available for duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Table of Contents

Usage

var remark = require('remark');
var vdom = require('remark-vdom');
var doc = remark().use(vdom).process(
    'Some _emphasis_, **strongness**, and `code`.'
);

Yields (note it’s an array of nodes):

[ VirtualNode {
    tagName: 'P',
    properties: {},
    children: 
     [ VirtualText { text: 'Some ' },
       VirtualNode {
         tagName: 'EM',
         properties: {},
         children: [ VirtualText { text: 'emphasis' } ],
         key: undefined,
         namespace: null,
         count: 1,
         hasWidgets: false,
         hasThunks: false,
         hooks: undefined,
         descendantHooks: false },
       VirtualText { text: ', ' },
       VirtualNode {
         tagName: 'STRONG',
         properties: {},
         children: [ VirtualText { text: 'strongness' } ],
         key: undefined,
         namespace: null,
         count: 1,
         hasWidgets: false,
         hasThunks: false,
         hooks: undefined,
         descendantHooks: false },
       VirtualText { text: ', and ' },
       VirtualNode {
         tagName: 'CODE',
         properties: {},
         children: [ VirtualText { text: 'code' } ],
         key: undefined,
         namespace: null,
         count: 1,
         hasWidgets: false,
         hasThunks: false,
         hooks: undefined,
         descendantHooks: false },
       VirtualText { text: '.' } ],
    key: undefined,
    namespace: null,
    count: 10,
    hasWidgets: false,
    hasThunks: false,
    hooks: undefined,
    descendantHooks: false },
  VirtualText { text: '\n' } ]

API

remark.use(vdom)

Parameters

  • vdom — This plugin.

Integrations

All mdast nodes can be compiled to HTML. Unknown mdast nodes are compiled to div nodes.

In addition, remark-vdom can be told how to compile nodes through three data properties:

  • htmlName — Tag-name to compile as;
  • htmlAttributes — Map of attributes to add.

For example, the following node:

{
  "type": "emphasis",
  "data": {
    "htmlName": "i",
    "htmlAttributes": {
      "id": "foo"
    }
  },
  "children": [{
    "type": "text",
    "value": "baz",
  }]
}

...would yield (when rendering):

<i id="foo">baz</i>

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 31 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc