
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
highlighter
Advanced tools
Add syntax highlighting to all files, with built-in syntax highlighting of diffs and patches.
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Highlighter provides a simple way to add syntax highlighting to all files by using highlight.js. Comes with built-in syntax highlighting for diffs and patches.
npm install highlighter --save
var highlight = require('highlighter')();
Highlighter can be used programmatically, by passing in the source string and the source language.
highlight('var foo = "bar";', 'javascript'); //=> '<span class="hljs-keyword">var</span> foo = <span class="hljs-string">"bar"</span>'
Highlighter returns a function that supports most markdown parsers already.
var marked = require('marked');
marked.setOptions({
highlight: highlight
});
Highlighter comes with complete diff support by appending .diff
or .patch
to the language name. This will wrap each section in a span with the section type class (diff-addition
, diff-deletion
, diff-header
, diff-chunk
or diff-null
).
highlight('+var foo = "bar";', 'js.diff'); //=> '<span class="diff-addition"><span class="hljs-keyword">var</span> foo = <span class="hljs-string">"bar"</span>;</span>'
This also works within Markdown files. The primary drawback of this approach causes the parent <code>
element to have the class appended with .diff
or .patch
, which may cause your specific CSS rules to fail. For example, <code class="lang-javascript.diff">
.
```javascript.diff
+var foo = "bar";
```
MIT
FAQs
Add syntax highlighting to all files, with built-in syntax highlighting of diffs and patches.
The npm package highlighter receives a total of 1,073 weekly downloads. As such, highlighter popularity was classified as popular.
We found that highlighter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.