hexo-util
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -97,8 +97,12 @@ 'use strict'; | ||
if (!lang && autoDetect) { | ||
loadAllLanguages(); | ||
lang = (function() { | ||
var result = hljs.highlightAuto(str); | ||
if (result.relevance > 0 && result.language) return result.language; | ||
return; | ||
})(); | ||
} | ||
if (!lang) { | ||
if (autoDetect) { | ||
loadAllLanguages(); | ||
return hljs.highlightAuto(str); | ||
} | ||
lang = 'plain'; | ||
@@ -126,3 +130,14 @@ } | ||
try { | ||
return hljs.highlight(lang, str); | ||
var matching = str.match(/(\r?\n)/); | ||
var separator = matching ? matching[1] : ''; | ||
var lines = matching ? str.split(separator) : [str]; | ||
var result = hljs.highlight(lang, lines.shift()); | ||
var html = result.value; | ||
while (lines.length > 0) { | ||
result = hljs.highlight(lang, lines.shift(), false, result.top); | ||
html += separator + result.value; | ||
} | ||
result.value = html; | ||
return result; | ||
} catch (err) { | ||
@@ -129,0 +144,0 @@ return; |
{ | ||
"name": "hexo-util", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Utilities for Hexo.", | ||
@@ -25,2 +25,5 @@ "main": "lib/index", | ||
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)", | ||
"maintainers": [ | ||
"Abner Chou <hi@abnerchou.me> (http://abnerchou.me)" | ||
], | ||
"license": "MIT", | ||
@@ -31,2 +34,3 @@ "devDependencies": { | ||
"eslint-config-hexo": "^1.0.3", | ||
"html-tag-validator": "^1.5.0", | ||
"istanbul": "^0.4.3", | ||
@@ -33,0 +37,0 @@ "jscs": "^3.0.4", |
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
32230
611
9
1