magicpen-prism
Advanced tools
Comparing version 0.3.0 to 1.0.0
@@ -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, '<'); // Prismism | ||
sourceText = sourceText.replace(/</g, '<'); // 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(/</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(/</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' | ||
); | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18347
560
1
1
5
1