remark-rehype
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -5,3 +5,3 @@ 'use strict'; | ||
module.exports = attacher; | ||
module.exports = remark2rehype; | ||
@@ -13,3 +13,3 @@ /* Attacher. | ||
* plug-ins run on that tree (mutate-mode). */ | ||
function attacher(destination, options) { | ||
function remark2rehype(destination, options) { | ||
if (destination && !destination.process) { | ||
@@ -16,0 +16,0 @@ options = destination; |
{ | ||
"name": "remark-rehype", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "rehype support for remark", | ||
@@ -27,11 +27,11 @@ "license": "MIT", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^10.0.0", | ||
"nyc": "^11.0.0", | ||
"rehype-stringify": "^3.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark-parse": "^3.0.0", | ||
"remark-preset-wooorm": "^2.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"remark-stringify": "^3.0.0", | ||
"tape": "^4.0.0", | ||
"unified": "^6.0.0", | ||
"xo": "^0.17.1" | ||
"xo": "^0.18.0" | ||
}, | ||
@@ -56,2 +56,3 @@ "scripts": { | ||
"space": true, | ||
"esnext": false, | ||
"ignores": [ | ||
@@ -58,0 +59,0 @@ "remark-rehype.js" |
@@ -15,23 +15,31 @@ # remark-rehype [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
```js | ||
Say we have the following file, `example.md`: | ||
```markdown | ||
# Hello world | ||
> Block quote. | ||
Some _emphasis_, **importance**, and `code`. | ||
``` | ||
And our script, `example.js`, looks as follows: | ||
```javascript | ||
var vfile = require('to-vfile'); | ||
var report = require('vfile-reporter'); | ||
var unified = require('unified'); | ||
var parse = require('remark-parse'); | ||
var markdown = require('remark-parse'); | ||
var remark2rehype = require('remark-rehype'); | ||
var highlight = require('rehype-highlight'); | ||
var stringify = require('rehype-stringify'); | ||
var report = require('vfile-reporter'); | ||
var doc = require('rehype-document'); | ||
var format = require('rehype-format'); | ||
var html = require('rehype-stringify'); | ||
unified() | ||
.use(parse) | ||
.use(markdown) | ||
.use(remark2rehype) | ||
.use(highlight) | ||
.use(stringify) | ||
.process([ | ||
'## Hello, world!', | ||
'', | ||
' "use strict"', | ||
' var name = "World";', | ||
' console.log("Hello, " + name + "!");', | ||
'' | ||
].join('\n'), function (err, file) { | ||
.use(doc) | ||
.use(format) | ||
.use(html) | ||
.process(vfile.readSync('example.md'), function (err, file) { | ||
console.error(report(err || file)); | ||
@@ -42,16 +50,21 @@ console.log(String(file)); | ||
**stderr**(4) yields: | ||
Now, running `node example` yields: | ||
```txt | ||
no issues found | ||
``` | ||
**stdout**(4) yields: | ||
```html | ||
<h2>Hello, world!</h2> | ||
<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> | ||
example.md: no issues found | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>example</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
<h1>Hello world</h1> | ||
<blockquote> | ||
<p>Block quote.</p> | ||
</blockquote> | ||
<p>Some <em>emphasis</em>, <strong>importance</strong>, and <code>code</code>.</p> | ||
</body> | ||
</html> | ||
``` | ||
@@ -78,2 +91,11 @@ | ||
## Related | ||
* [`rehype-remark`](https://github.com/wooorm/rehype-remark) | ||
— Transform HTML to markdown | ||
* [`rehype-retext`](https://github.com/wooorm/rehype-retext) | ||
— Transform HTML to [NLCST][] | ||
* [`remark-retext`](https://github.com/wooorm/remark-retext) | ||
— Transform markdown to [NLCST][] | ||
## License | ||
@@ -112,1 +134,3 @@ | ||
[to-hast]: https://github.com/wooorm/mdast-util-to-hast#tohastnode-options | ||
[nlcst]: https://github.com/syntax-tree/nlcst |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6922
133