hexo-renderer-marked
Advanced tools
Comparing version 0.1.0 to 0.2.3
64
index.js
@@ -1,56 +0,14 @@ | ||
var marked = require('marked'), | ||
_ = require('lodash'), | ||
util = hexo.util, | ||
highlight = util.highlight, | ||
htmlTag = util.html_tag, | ||
format = util.format, | ||
stripHtml = format.stripHtml, | ||
headingId = {}; | ||
var renderer = require('./lib/renderer'); | ||
var assign = require('object-assign'); | ||
var anchorId = function(str){ | ||
return str | ||
.replace(/\s+/g, '_') | ||
.replace(/\./g, '-') | ||
.replace(/-{2,}/g, '-'); | ||
}; | ||
hexo.config.marked = assign({ | ||
gfm: true, | ||
pedantic: false, | ||
sanitize: false, | ||
tables: true, | ||
breaks: true, | ||
smartLists: true, | ||
smartypants: true | ||
}, hexo.config.marked); | ||
var r = new marked.Renderer(); | ||
// Add id attribute to headings | ||
r.heading = function(text, level){ | ||
var id = anchorId(stripHtml(text)); | ||
// Add a number after id if repeated | ||
if (headingId.hasOwnProperty(id)){ | ||
id += '-' + headingId[id]; | ||
headingId[text]++; | ||
} else { | ||
headingId[id] = 1; | ||
} | ||
return htmlTag('h' + level, {id: id}, text) + '\n'; | ||
}; | ||
marked.setOptions({ | ||
renderer: r, | ||
langPrefix: '', | ||
highlight: function(code, lang){ | ||
return highlight(code, {lang: lang, gutter: false, wrap: false}); | ||
} | ||
}); | ||
var renderer = function(data, options){ | ||
headingId = {}; | ||
return marked(data.text, _.extend({ | ||
gfm: true, | ||
pedantic: false, | ||
sanitize: false, | ||
tables: true, | ||
breaks: true, | ||
smartLists: true, | ||
smartypants: true | ||
}, hexo.config.marked, options)); | ||
}; | ||
hexo.extend.renderer.register('md', 'html', renderer, true); | ||
@@ -57,0 +15,0 @@ hexo.extend.renderer.register('markdown', 'html', renderer, true); |
{ | ||
"name": "hexo-renderer-marked", | ||
"version": "0.1.0", | ||
"version": "0.2.3", | ||
"description": "Markdown renderer plugin for Hexo", | ||
"main": "index", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hexojs/hexo-renderer-marked.git" | ||
"scripts": { | ||
"test": "gulp test" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hexojs/hexo-renderer-marked/issues" | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
}, | ||
"repository": "hexojs/hexo-renderer-marked", | ||
"keywords": [ | ||
@@ -20,10 +23,21 @@ "hexo", | ||
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)", | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://raw.github.com/tommy351/hexo/master/LICENSE" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"hexo-util": "^0.1.0", | ||
"marked": "^0.3.2", | ||
"lodash": "^2.4.1" | ||
"object-assign": "^2.0.0", | ||
"strip-indent": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^1.9.1", | ||
"coveralls": "^2.11.2", | ||
"gulp": "^3.8.9", | ||
"gulp-istanbul": "^0.5.0", | ||
"gulp-jshint": "^1.8.6", | ||
"gulp-load-plugins": "^0.8.0", | ||
"gulp-mocha": "^2.0.0", | ||
"jshint-stylish": "^1.0.0", | ||
"mocha": "^2.0.1", | ||
"rimraf": "^2.2.8" | ||
} | ||
} |
@@ -1,6 +0,8 @@ | ||
# [Markdown] renderer | ||
# hexo-renderer-marked | ||
[](https://travis-ci.org/hexojs/hexo-renderer-marked) [](http://badge.fury.io/js/hexo-renderer-marked) [](https://coveralls.io/r/hexojs/hexo-renderer-marked?branch=master) | ||
Add support for [Markdown]. This plugin uses [marked] as render engine. | ||
## Install | ||
## Installation | ||
@@ -7,0 +9,0 @@ ``` bash |
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
5648
6
61
37
4
10
1
1
+ Addedhexo-util@^0.1.0
+ Addedobject-assign@^2.0.0
+ Addedstrip-indent@^1.0.0
+ Addedbluebird@2.11.0(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedent@2.2.2(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.3.0(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedget-stdin@4.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhexo-util@0.1.7(transitive)
+ Addedhighlight.js@8.9.1(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedstrip-indent@1.0.1(transitive)
- Removedlodash@^2.4.1
- Removedlodash@2.4.2(transitive)