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

rehype-document

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-document

Wrap a document around the syntax tree

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
increased by14.31%
Maintainers
1
Weekly downloads
 
Created
Source

rehype-document Build Status Coverage Status

Wrap a document around HTML with rehype.

Installation

npm:

npm install rehype-document

Usage

Say example.md looks as follows:

## Hello world!

This is **my** document.

...and example.js like this:

var vfile = require('to-vfile')
var report = require('vfile-reporter')
var unified = require('unified')
var parse = require('remark-parse')
var mutate = require('remark-rehype')
var stringify = require('rehype-stringify')
var doc = require('rehype-document')

unified()
  .use(parse)
  .use(mutate)
  .use(doc, {title: 'Hi!'})
  .use(stringify)
  .process(vfile.readSync('example.md'), function(err, file) {
    console.error(report(err || file))
    console.log(String(file))
  })

Now, running node example yields:

example.md: no issues found
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h2>Hello world!</h2>
<p>This is <strong>my</strong> document.</p>
</body>
</html>

API

rehype().use(document[, options])

Wrap a document around a fragment.

options
options.title

string, default: name of file, if any — Text to use as title.

options.language

string, default: 'en' — Natural language of document (BCP 47).

options.responsive

boolean, default: true — Whether to insert a meta[viewport].

options.doctype

string, default: '5'Doctype to use.

options.css

string or Array.<string>, default: [] — Stylesheets to include in head.

options.meta

Object or Array.<Object>, default: [] — Metadata to include in head. Each object is passed as properties to hastscript with a meta element.

Object or Array.<Object>, default: [] — Link tags to include in head. Each object is passed as properties to hastscript with a link element.

options.js

string or Array.<string>, default: [] — Scripts to include at end of body.

Contribute

See contributing.md in rehypejs/rehype for ways to get started.

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

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 01 Sep 2018

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