Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-rehype

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-rehype - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

56

index.js

@@ -11,48 +11,30 @@ /**

/* eslint-env commonjs */
/* Dependencies */
var mdast2hast = require('mdast-util-to-hast');
/**
* Mutate-mode. Further transformers run on the HAST tree.
*
* @param {MDASTNode} node - Tree.
* @return {HASTNode} - Tree.
*/
function mutate(node) {
return mdast2hast(node);
}
/* Expose. */
module.exports = attacher;
/**
* Bridge-mode. Runs the destination with the new HAST
* tree.
*
* @param {Unified} destination - Destination processor.
* @return {Function} - Transformer.
*/
function bridge(destination) {
return function (node, file, next) {
destination.run(mdast2hast(node), file, function (err) {
next(err);
});
};
}
/**
* Attacher.
/* Attacher.
* If a destination is given, runs the destination with
* the new HAST tree (bridge-mode).
* Without destination, returns the HAST tree: further
* plug-ins run on that tree (mutate-mode).
*
* @param {Unified} origin - Origin processor.
* @param {Unified} [destination] - Destination processor.
* @return {Function} - Transformer.
*/
* plug-ins run on that tree (mutate-mode). */
function attacher(origin, destination) {
return destination ? bridge(destination) : mutate;
return destination ? bridge(destination) : mutate;
}
/* Expose. */
module.exports = attacher;
/* Bridge-mode. Runs the destination with the new HAST
* tree. */
function bridge(destination) {
return function (node, file, next) {
destination.run(mdast2hast(node), file, function (err) {
next(err);
});
};
}
/* Mutate-mode. Further transformers run on the HAST tree. */
function mutate(node) {
return mdast2hast(node);
}
{
"name": "remark-rehype",
"version": "1.0.0",
"version": "1.0.1",
"description": "rehype support for remark",

@@ -12,9 +12,3 @@ "license": "MIT",

],
"files": [
"index.js"
],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/remark-rehype.git"
},
"repository": "https://github.com/wooorm/remark-rehype",
"bugs": "https://github.com/wooorm/remark-rehype/issues",

@@ -28,22 +22,17 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

},
"files": [
"index.js"
],
"devDependencies": {
"browserify": "^13.0.1",
"eslint": "^2.0.0",
"esmangle": "^1.0.1",
"istanbul": "^0.4.0",
"jscs": "^3.0.0",
"jscs-jsdoc": "^2.0.0",
"rehype-highlight": "^1.0.0",
"rehype-stringify": "^1.0.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-parse": "^1.0.0",
"remark-stringify": "^1.0.0",
"remark-validate-links": "^4.0.0",
"nyc": "^8.1.0",
"rehype-stringify": "^2.0.0",
"remark-cli": "^2.0.0",
"remark-parse": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"remark-stringify": "^2.0.0",
"tape": "^4.0.0",
"unified": "^4.1.2",
"unist-util-inspect": "^4.0.0",
"vfile-reporter": "^1.5.0"
"unified": "^5.0.0",
"xo": "^0.16.0"
},

@@ -55,9 +44,23 @@ "scripts": {

"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint-api": "eslint .",
"lint-style": "jscs --reporter inline .",
"lint": "npm run lint-api && npm run lint-style",
"lint": "xo",
"test-api": "node test.js",
"test-coverage": "istanbul cover test.js",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"xo": {
"space": true,
"ignores": [
"remark-rehype.js"
]
},
"remarkConfig": {
"output": true,
"presets": "wooorm"
}
}

@@ -17,33 +17,34 @@ # remark-rehype [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

```javascript
var unified = require('unified');
var parse = require('remark-parse');
var lint = require('remark-lint');
var remark2rehype = require('remark-rehype');
var highlight = require('rehype-highlight');
var stringify = require('rehype-stringify');
var report = require('vfile-reporter');
```js
var unified = require('unified');
var parse = require('remark-parse');
var remark2rehype = require('remark-rehype');
var highlight = require('rehype-highlight');
var stringify = require('rehype-stringify');
var report = require('vfile-reporter');
unified()
.use(parse)
.use(lint)
.use(remark2rehype)
.use(highlight)
.use(stringify)
.process([
'## Hello, world!',
'',
'~~~js',
'var name = "World";',
'console.log("Hello, " + name + "!");',
'~~~',
''
].join('\n'), function (err, file) {
file.filename = 'example';
file.extension = 'md';
process.stdout.write(file + '\n');
process.stderr.write(report(file) + '\n');
});
unified()
.use(parse)
.use(remark2rehype)
.use(highlight)
.use(stringify)
.process([
'## Hello, world!',
'',
' "use strict"',
' var name = "World";',
' console.log("Hello, " + name + "!");',
''
].join('\n'), function (err, file) {
console.error(report(err || file));
console.log(String(file));
});
```
**stderr**(4) yields:
```txt
no issues found
```
**stdout**(4) yields:

@@ -53,17 +54,8 @@

<h2>Hello, world!</h2>
<pre><code class="hljs language-js"><span class="hljs-keyword">var</span> name = <span class="hljs-string">&#x22;World&#x22;</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x22;Hello, &#x22;</span> + name + <span class="hljs-string">&#x22;!&#x22;</span>);
<pre><code class="hljs language-javascript"><span class="hljs-meta">"use strict"</span>
<span class="hljs-keyword">var</span> name = <span class="hljs-string">"World"</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, "</span> + name + <span class="hljs-string">"!"</span>);
</code></pre>
```
**stderr**(4) yields:
```txt
example.md
1-1:17 warning First heading level should be `1` first-heading-level
1-1:17 warning Don’t add a trailing `!` to headings no-heading-punctuation
⚠ 2 warnings
```
## API

@@ -70,0 +62,0 @@

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