Socket
Socket
Sign inDemoInstall

rehype-highlight

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-highlight - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

18

package.json
{
"name": "rehype-highlight",
"version": "2.0.0",
"version": "2.0.1",
"description": "Highlight code blocks",

@@ -10,3 +10,3 @@ "license": "MIT",

"syntax",
"highligh",
"highlight",
"highlighting"

@@ -31,9 +31,8 @@ ],

"esmangle": "^1.0.1",
"nyc": "^10.0.0",
"rehype": "^4.0.0",
"nyc": "^11.0.0",
"rehype": "^5.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^2.0.0",
"remark-preset-wooorm": "^3.0.0",
"tape": "^4.0.0",
"unist-util-inspect": "^4.0.0",
"xo": "^0.17.1"
"xo": "^0.18.0"
},

@@ -58,2 +57,3 @@ "scripts": {

"space": true,
"esnext": false,
"ignores": [

@@ -64,4 +64,6 @@ "rehype-highlight.js"

"remarkConfig": {
"plugins": ["preset-wooorm"]
"plugins": [
"preset-wooorm"
]
}
}

@@ -15,26 +15,36 @@ # rehype-highlight [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

Say `example.html` looks as follows:
```html
<h1>Hello World!</h1>
<pre><code class="language-js">var name = "World";
console.warn("Hello, " + name + "!")</code></pre>
```
...and `example.js` like this:
```javascript
var vfile = require('to-vfile');
var report = require('vfile-reporter');
var rehype = require('rehype');
var highlight = require('rehype-highlight');
var file = rehype()
rehype()
.data('settings', {fragment: true})
.use(highlight)
.processSync([
'<h1>Hello World!</h1>',
'',
'<pre><code class="language-js">var name = "World";',
'console.warn("Hello, " + name + "!")</code></pre>'
].join('\n'));
console.log(String(file));
.process(vfile.readSync('example.html'), function (err, file) {
console.error(report(err || file));
console.log(String(file));
});
```
Yields:
Now, running `node example` yields:
```html
example.html: no issues found
<h1>Hello World!</h1>
<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>.warn(<span class="hljs-string">&#x22;Hello, &#x22;</span> + name + <span class="hljs-string">&#x22;!&#x22;</span>)</code></pre>
<pre><code class="hljs language-js"><span class="hljs-keyword">var</span> name = <span class="hljs-string">"World"</span>;
<span class="hljs-built_in">console</span>.warn(<span class="hljs-string">"Hello, "</span> + name + <span class="hljs-string">"!"</span>)</code></pre>
```

@@ -53,10 +63,14 @@

###### `options`
##### `options`
* `prefix` (`string`, default: `'hljs-'`)
— Prefix to use before classes;
* `subset` (`boolean` or `Array.<string>`, default: all languages)
— Scope of languages to check when auto-detecting.
Pass `false` to not highlight code without language classes.
###### `options.prefix`
`string`, default: `'hljs-'` — Prefix to use before classes.
###### `options.subset`
`boolean` or `Array.<string>`, default: all languages — Scope of languages to
check when auto-detecting. Pass `false` to not highlight code without
language classes.
## License

@@ -63,0 +77,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