Socket
Socket
Sign inDemoInstall

hexo-util

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-util - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

build/highlight_alias.json

38

lib/highlight.js
'use strict';
var hljs = require('highlight.js/lib/highlight');
var Entities = require('html-entities').XmlEntities;
var entities = new Entities();
var hljs;
var alias = require('../build/highlight_alias.json');
hljs.configure({
classPrefix: ''
});
module.exports = function(str, options) {

@@ -11,4 +16,2 @@ if (typeof str !== 'string') throw new TypeError('str must be a string!');

if (!hljs) initHighlight();
var gutter = options.hasOwnProperty('gutter') ? options.gutter : true;

@@ -55,10 +58,2 @@ var wrap = options.hasOwnProperty('wrap') ? options.wrap : true;

function initHighlight() {
hljs = require('highlight.js');
hljs.configure({
classPrefix: ''
});
}
function encodePlainString(str) {

@@ -80,2 +75,20 @@ return entities.encode(str);

function loadLanguage(lang) {
hljs.registerLanguage(lang, require('highlight.js/lib/languages/' + lang));
}
function tryLanguage(lang) {
if (hljs.getLanguage(lang)) return true;
if (!alias.aliases[lang]) return false;
loadLanguage(alias.aliases[lang]);
return true;
}
function loadAllLanguages() {
alias.languages.filter(function(lang) {
return !hljs.getLanguage(lang);
}).forEach(loadLanguage);
}
function highlight(str, options) {

@@ -87,2 +100,3 @@ var lang = options.lang;

if (autoDetect) {
loadAllLanguages();
return hljs.highlightAuto(str);

@@ -103,3 +117,3 @@ }

if (!hljs.getLanguage(result.language)) {
if (!tryLanguage(result.language)) {
result.language = 'plain';

@@ -106,0 +120,0 @@ return result;

'use strict';
var hash = require('./hash');
exports.escapeDiacritic = require('./escape_diacritic');

@@ -15,1 +17,3 @@ exports.escapeHTML = require('./escape_html');

exports.wordWrap = require('./word_wrap');
exports.hash = hash.hash;
exports.HashStream = hash.HashStream;
{
"name": "hexo-util",
"version": "0.2.1",
"version": "0.3.0",
"description": "Utilities for Hexo.",

@@ -15,5 +15,2 @@ "main": "lib/index",

},
"engines": {
"node": ">= 0.10.0"
},
"repository": "hexojs/hexo-util",

@@ -29,13 +26,15 @@ "homepage": "http://hexo.io/",

"devDependencies": {
"chai": "^3.4.0",
"eslint": "^1.8.0",
"istanbul": "^0.4.0",
"jscs": "^2.5.0",
"mocha": "^2.3.3"
"chai": "^3.4.1",
"eslint": "^1.10.3",
"eslint-config-hexo": "^1.0.2",
"istanbul": "^0.4.1",
"jscs": "^2.6.0",
"jscs-preset-hexo": "^1.0.1",
"mocha": "^2.3.4"
},
"dependencies": {
"bluebird": "^3.0.5",
"highlight.js": "^8.9.1",
"bluebird": "^3.0.6",
"highlight.js": "^9.0.0",
"html-entities": "^1.2.0"
}
}

@@ -31,2 +31,25 @@ # hexo-util

### hash(str)
Generates SHA1 hash.
``` js
hash('123456');
// <Buffer 7c 4a 8d 09 ca 37 62 af 61 e5 95 20 94 3d c2 64 94 f8 94 1b>
```
### HashStream()
Generates SHA1 hash with a transform stream.
``` js
var stream = new HashStream();
fs.createReadStream('/path/to/file')
.pipe(stream)
.on('finish', function(){
console.log(stream.read());
});
```
### highlight(str, [options])

@@ -33,0 +56,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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