Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ultramarked

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ultramarked - npm Package Compare versions

Comparing version 0.5.5 to 0.6.0

6

package.json

@@ -10,3 +10,3 @@ {

},
"version": "0.5.5",
"version": "0.6.0",
"repository": {

@@ -21,4 +21,4 @@ "type": "git",

"he": "^0.4.1",
"highlight.js": "~7.3.0",
"marked": "~0.2.9"
"highlight.js": "^8.0.0",
"marked": "^0.3.2"
},

@@ -25,0 +25,0 @@ "engines": {

@@ -25,3 +25,3 @@ # ultramarked

Syntax highlighting powered by [highlight.js](https://github.com/isagalaev/highlight.js), no extra magic.
Syntax highlighting powered by [highlight.js](https://github.com/isagalaev/highlight.js), no extra magic. Classes are prefixed `hljs` for convenience.

@@ -28,0 +28,0 @@ ### options.ultrasanitize

@@ -13,2 +13,4 @@ 'use strict';

hljs.configure({ classPrefix: 'hljs-' });
function merge(obj) {

@@ -29,2 +31,22 @@ var i = 1, target, key;

function getHighlightingRenderer () {
var renderer = new marked.Renderer();
var baseCodeRenderer = renderer.code;
var baseCodeSpanRenderer = renderer.codespan;
renderer.code = function () {
var result = baseCodeRenderer.apply(this, arguments);
var classed = result.replace(/^<pre><code>/i, '<pre class="hljs-pre"><code class="hljs">');
console.log(result);
return classed;
};
renderer.codespan = function () {
var result = baseCodeSpanRenderer.apply(this, arguments);
var classed = result.replace(/^<code>/i, '<code class="hljs">');
console.log(result);
return classed;
};
return renderer;
}
function ultramarked(src, opt) {

@@ -38,3 +60,6 @@ var options = merge({}, marked.defaults, opt),

options.highlight = function (code, lang) {
var lower = (lang || no).toLowerCase();
if (!lang) {
return code;
}
var lower = lang.toLowerCase();
try{

@@ -44,2 +69,3 @@ return hljs.highlight(aliases[lower] || lower, code).value;

};
options.renderer = getHighlightingRenderer();
}

@@ -50,9 +76,10 @@

if(options.ultralight){ // fix the language class using common aliases
result = result.replace(/"ultralight-lang-([\w-]+)"/ig, function(match, lang){
if (options.ultralight) { // fix the language class using common aliases
result = result.replace(/"ultralight-lang-([\w-]+)"/ig, function (match, lang) {
var lower = lang.toLowerCase(),
result = aliases[lower] || lower || no;
return '"' + result + '"';
return '"hljs ' + result + '"';
});
result = result.replace(/^<pre>/, '<pre class="hljs-pre">');
}

@@ -59,0 +86,0 @@

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