
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
highlighter
Advanced tools
Add syntax highlighting to all files, with built-in syntax highlighting of diffs and patches.
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.
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.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.