
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Sunlight highlighter modernized for node.js. Here is the demo of sunlight-x.
Type yarn add sunlight-x or npm install --save sunlight-x in the console.
var sunlight = require("sunlight-x");
var highlighter = new sunlight.Highlighter();
var code = "console.log('Hello world!');";
var language = "javascript";
highlighter.highlightCode(code, language);
Options available to the highlighter is shown below with their defaults.
You can pass any or all of these options to new sunlight.Highlighter().
var sunlight = require("sunlight-x");
var options = {
// Main highlighter
theme: "gitbook", // The theme.
tabWidth: 4, // Width of a tab character.
classPrefix: "sunlight-", // Style prefix. Custom stylesheet needed.
showWhitespace: false, // Whether to show invisible tabs and whitespaces.
maxHeight: false, // Max height of code container. False = no limit.
// Line number plugin (loaded automatically)
lineNumbers: false, // Whether to show line numbers.
lineNumberStart: 1, // The starting number line if line numbers are shown.
lineHighlight: [] // List of line numbers to be highlighted.
};
var highlighter = new sunlight.Highlighter(options);
var code = "console.log('Hello world!');";
var language = "javascript";
highlighter.highlightCode(code, language);
Caution: Do NOT modify the content of Highlighter.options.
Highlighter.options be made immutable in the future.
To change the options, make a different instance of Highlighter instead.
var sunlight = require("sunlight-x");
var highlighter = new sunlight.Highlighter();
/**
* Highlights the given code and returns the HTML as a string.
* @param {string} code
* @param {string} languageId
* @returns {Element}
*/
var html = highlighter.highlightCode(code, languageId);
/**
* Highlights the given code and returns the HTML Element.
* @param {string} code
* @param {string} languageId
* @returns {Element}
*/
var element = highlighter.highlightCodeAsElement(code, languageId);
Now advanced usages of the highlighter is shown below, which is used to add an language to the highlighter. Read the source or the old sunlight doc for more details.
var sunlight = require("sunlight-x");
// Add a language to the highlighter. This is GLOBAL.
var language = ... // the language definition.
sunlight.registerLanguage(language);
// See if the language is registered. This is GLOBAL.
var isRegistered = sunlight.isRegistered(language)
Copyright 2017-18 Leung Wing-chung. All rights reserved. Use of the software by a Apache License Version 2.0, that can be found in the LICENSE file.
This software is forked from Sunlight, authored by Tommy Montgomery. The original Sunlight is licensed by the WTFPL (warning: foul language inside).
FAQs
Sunlight highlighter refactored for Node.js
The npm package sunlight-x receives a total of 23 weekly downloads. As such, sunlight-x popularity was classified as not popular.
We found that sunlight-x 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.