Socket
Socket
Sign inDemoInstall

marked-highlight

Package Overview
Dependencies
1
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.9 to 2.1.0

12

lib/index.umd.js

@@ -29,9 +29,9 @@ (function (global, factory) {

const lang = getLang(token);
const lang = getLang(token.lang);
if (options.async) {
return Promise.resolve(options.highlight(token.text, lang)).then(updateToken(token));
return Promise.resolve(options.highlight(token.text, lang, token.lang || '')).then(updateToken(token));
}
const code = options.highlight(token.text, lang);
const code = options.highlight(token.text, lang, token.lang || '');
if (code instanceof Promise) {

@@ -44,3 +44,3 @@ throw new Error('markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.');

code(code, infoString, escaped) {
const lang = (infoString || '').match(/\S*/)[0];
const lang = getLang(infoString);
const classAttr = lang

@@ -56,4 +56,4 @@ ? ` class="${options.langPrefix}${escape(lang)}"`

function getLang(token) {
return (token.lang || '').match(/\S*/)[0];
function getLang(lang) {
return (lang || '').match(/\S*/)[0];
}

@@ -60,0 +60,0 @@

{
"name": "marked-highlight",
"version": "2.0.9",
"version": "2.1.0",
"description": "marked highlight",

@@ -47,22 +47,22 @@ "main": "./lib/index.cjs",

"devDependencies": {
"@babel/core": "^7.23.5",
"@babel/preset-env": "^7.23.5",
"@babel/core": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.2.4",
"@semantic-release/npm": "^11.0.1",
"@semantic-release/github": "^9.2.5",
"@semantic-release/npm": "^11.0.2",
"@semantic-release/release-notes-generator": "^12.1.0",
"babel-jest": "^29.7.0",
"eslint": "^8.54.0",
"eslint": "^8.55.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-n": "^16.4.0",
"eslint-plugin-promise": "^6.1.1",
"highlight.js": "^11.9.0",
"jest-cli": "^29.7.0",
"marked": "^11.0.0",
"marked": "^11.0.1",
"pygmentize-bundled": "^2.3.0",
"rollup": "^4.6.1",
"semantic-release": "^22.0.8",
"rollup": "^4.8.0",
"semantic-release": "^22.0.10",
"tsd": "^0.29.0"

@@ -69,0 +69,0 @@ },

@@ -21,3 +21,3 @@ # marked-highlight

langPrefix: 'hljs language-',
highlight(code, lang) {
highlight(code, lang, info) {
const language = hljs.getLanguage(lang) ? lang : 'plaintext';

@@ -50,3 +50,3 @@ return hljs.highlight(code, { language }).value;

async: true,
highlight(code, lang) {
highlight(code, lang, info) {
return new Promise((resolve, reject) => {

@@ -53,0 +53,0 @@ pygmentize({ lang, format: 'html' }, code, function (err, result) {

@@ -8,5 +8,7 @@ declare module 'marked-highlight' {

* opening marker (e.g. ```typescript -> language='typescript')
* @param info The full string after the code block opening marker
* (e.g. ```ts twoslash -> info='ts twoslash')
* @return The highlighted code as a HTML string
*/
type SyncHighlightFunction = (code: string, language: string) => string;
type SyncHighlightFunction = (code: string, language: string, info: string) => string;

@@ -19,5 +21,7 @@ /**

* opening marker (e.g. ```typescript -> language='typescript')
* @param info The full string after the code block opening marker
* (e.g. ```ts twoslash -> info='ts twoslash')
* @return A Promise for the highlighted code as a HTML string
*/
type AsyncHighlightFunction = (code: string, language: string) => Promise<string>;
type AsyncHighlightFunction = (code: string, language: string, info: string) => Promise<string>;

@@ -24,0 +28,0 @@ /**

@@ -23,9 +23,9 @@ export function markedHighlight(options) {

const lang = getLang(token);
const lang = getLang(token.lang);
if (options.async) {
return Promise.resolve(options.highlight(token.text, lang)).then(updateToken(token));
return Promise.resolve(options.highlight(token.text, lang, token.lang || '')).then(updateToken(token));
}
const code = options.highlight(token.text, lang);
const code = options.highlight(token.text, lang, token.lang || '');
if (code instanceof Promise) {

@@ -38,3 +38,3 @@ throw new Error('markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.');

code(code, infoString, escaped) {
const lang = (infoString || '').match(/\S*/)[0];
const lang = getLang(infoString);
const classAttr = lang

@@ -50,4 +50,4 @@ ? ` class="${options.langPrefix}${escape(lang)}"`

function getLang(token) {
return (token.lang || '').match(/\S*/)[0];
function getLang(lang) {
return (lang || '').match(/\S*/)[0];
}

@@ -54,0 +54,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc