New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

magicpen-prism

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magicpen-prism - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

65

lib/magicPenPrism.js

@@ -55,41 +55,44 @@ var prism = require('../3rdparty/prism'),

module.exports = function magicPenPrism(magicPen) {
Object.keys(colorByTokenType).forEach(function (tokenType) {
magicPen.addStyle('prism:' + tokenType, function (content) {
this.text(content, colorByTokenType[tokenType]);
module.exports = {
name: 'magicpen-prism',
installInto: function (magicPen) {
Object.keys(colorByTokenType).forEach(function (tokenType) {
magicPen.addStyle('prism:' + tokenType, function (content) {
this.text(content, colorByTokenType[tokenType]);
});
});
});
magicPen.addStyle('code', function (sourceText, language) {
if (language in languageMapping) {
language = languageMapping[language];
}
if (!(language in prism.languages)) {
return this.text(sourceText);
}
magicPen.addStyle('code', function (sourceText, language) {
if (language in languageMapping) {
language = languageMapping[language];
}
if (!(language in prism.languages)) {
return this.text(sourceText);
}
sourceText = sourceText.replace(/</g, '&lt;'); // Prismism
sourceText = sourceText.replace(/</g, '&lt;'); // Prismism
var that = this;
var that = this;
function printTokens(token, parentStyle) {
if (Array.isArray(token)) {
token.forEach(function (subToken) {
printTokens(subToken, parentStyle);
});
} else if (typeof token === 'string') {
token = token.replace(/&lt;/g, '<');
if (that['prism:' + language + ':' + parentStyle]) {
that['prism:' + language + ':' + parentStyle](token);
} else if (that['prism:' + parentStyle]) {
that['prism:' + parentStyle](token);
function printTokens(token, parentStyle) {
if (Array.isArray(token)) {
token.forEach(function (subToken) {
printTokens(subToken, parentStyle);
});
} else if (typeof token === 'string') {
token = token.replace(/&lt;/g, '<');
if (that['prism:' + language + ':' + parentStyle]) {
that['prism:' + language + ':' + parentStyle](token);
} else if (that['prism:' + parentStyle]) {
that['prism:' + parentStyle](token);
} else {
that.text(token);
}
} else {
that.text(token);
printTokens(token.content, token.type);
}
} else {
printTokens(token.content, token.type);
}
}
printTokens(prism.tokenize(sourceText, prism.languages[language]), 'text');
}, true);
printTokens(prism.tokenize(sourceText, prism.languages[language]), 'text');
}, true);
}
};
{
"name": "magicpen-prism",
"version": "0.3.0",
"version": "1.0.0",
"description": "Add syntax highlighting support to magicpen via prism.js",
"main": "lib/magicPenPrism.js",
"author": "Andreas Lind Petersen <andreas@one.com>",
"peerDependencies": {
"magicpen": "^4.0.0"
},
"devDependencies": {
"magicpen": "1.0.0",
"magicpen": "4.0.0",
"mocha": "1.21.4",
"unexpected": "5.0.0-beta23"
"unexpected": "5.0.0-beta36",
"browserify": "^5.9.1",
"bundle-collapser": "^1.1.0"
},

@@ -12,0 +17,0 @@ "scripts": {

@@ -39,5 +39,5 @@ var expect = require('unexpected'),

'to equal',
'int \u001b[31m\u001b[38;5;204mmain\u001b[39m\u001b[90m\u001b[38;5;247m(\u001b[39mint argc\u001b[90m\u001b[38;5;247m,\u001b[39m char \u001b[90m\u001b[38;5;180m*\u001b[39m\u001b[90m\u001b[38;5;180m*\u001b[39margv\u001b[90m\u001b[38;5;247m)\u001b[39m \u001b[90m\u001b[38;5;247m{\u001b[39m\u001b[90m\u001b[38;5;247m}\u001b[39m'
'int \u001b[31m\u001b[38;5;204mmain\u001b[39m\u001b[90m\u001b[38;5;247m(\u001b[39mint argc\u001b[90m\u001b[38;5;247m,\u001b[39m char \u001b[90m\u001b[38;5;180m**\u001b[39margv\u001b[90m\u001b[38;5;247m)\u001b[39m \u001b[90m\u001b[38;5;247m{}\u001b[39m'
);
});
});
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