hexo-renderer-marked
Advanced tools
Comparing version 0.3.2 to 1.0.0
@@ -6,5 +6,4 @@ /* global hexo */ | ||
var renderer = require('./lib/renderer'); | ||
var assign = require('object-assign'); | ||
hexo.config.marked = assign({ | ||
hexo.config.marked = Object.assign({ | ||
gfm: true, | ||
@@ -11,0 +10,0 @@ pedantic: false, |
'use strict'; | ||
var marked = require('marked'); | ||
var assign = require('object-assign'); | ||
var stripIndent = require('strip-indent'); | ||
@@ -20,16 +19,2 @@ var util = require('hexo-util'); | ||
// Support To-Do List | ||
Renderer.prototype.listitem = function(text) { | ||
var result; | ||
if (/^\s*\[[x ]\]\s*/.test(text)) { | ||
text = text.replace(/^\s*\[ \]\s*/, '<input type="checkbox"></input> ').replace(/^\s*\[x\]\s*/, '<input type="checkbox" checked></input> '); | ||
result = '<li style="list-style: none">' + text + '</li>\n'; | ||
} else { | ||
result = '<li>' + text + '</li>\n'; | ||
} | ||
return result; | ||
}; | ||
// Add id attribute to headings | ||
@@ -87,2 +72,22 @@ Renderer.prototype.heading = function(text, level) { | ||
// Support Basic Description Lists | ||
Renderer.prototype.paragraph = function(text) { | ||
var result = ''; | ||
var dlTest = /(^|\s)(\S.+)(<br>:(\s+))(\S.+)/; | ||
var dl | ||
= '<dl>' | ||
+ '<dt>$2</dt>' | ||
+ '<dd>$5</dd>' | ||
+ '</dl>'; | ||
if (text.match(dlTest)) { | ||
result = text.replace(dlTest, dl); | ||
} else { | ||
result = '<p>' + text + '</p>\n'; | ||
} | ||
return result; | ||
}; | ||
marked.setOptions({ | ||
@@ -100,5 +105,5 @@ langPrefix: '', | ||
module.exports = function(data, options) { | ||
return marked(data.text, assign({ | ||
return marked(data.text, Object.assign({ | ||
renderer: new Renderer() | ||
}, this.config.marked, options)); | ||
}; |
{ | ||
"name": "hexo-renderer-marked", | ||
"version": "0.3.2", | ||
"version": "1.0.0", | ||
"description": "Markdown renderer plugin for Hexo", | ||
@@ -8,3 +8,2 @@ "main": "index", | ||
"eslint": "eslint .", | ||
"jscs": "jscs .", | ||
"test": "mocha test/index.js", | ||
@@ -30,4 +29,3 @@ "test-cov": "istanbul cover --print both _mocha -- test/index.js" | ||
"hexo-util": "^0.6.2", | ||
"marked": "^0.3.9", | ||
"object-assign": "^4.1.1", | ||
"marked": "^0.6.1", | ||
"strip-indent": "^2.0.0" | ||
@@ -37,10 +35,11 @@ }, | ||
"chai": "^4.1.2", | ||
"eslint": "^4.13.1", | ||
"babel-eslint": "^8.0.3", | ||
"eslint-config-hexo": "^2.0.0", | ||
"eslint": "^5.9.0", | ||
"babel-eslint": "^10.0.1", | ||
"eslint-config-hexo": "^3.0.0", | ||
"istanbul": "^0.4.5", | ||
"jscs": "^3.0.7", | ||
"jscs-preset-hexo": "^1.0.1", | ||
"mocha": "^4.0.1" | ||
"mocha": "^6.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=6.9.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ # hexo-renderer-marked | ||
Add support for [Markdown]. This plugin uses [marked] as render engine. | ||
Add support for [Markdown]. This plugin uses [marked] as its render engine. | ||
@@ -43,6 +43,50 @@ ## Installation | ||
- **smartypants** - Use "smart" typograhic punctuation for things like quotes and dashes. | ||
- **modifyAnchors** - Use for transform anchorIds. if 1 to lowerCase and if 2 to upperCase. | ||
- **modifyAnchors** - Use for transform anchorIds. if `1` to lowerCase and if `2` to upperCase. **Must be integer**. | ||
- **autolink** - Enable autolink for URLs. E.g. `https://hexo.io` will become `<a href="https://hexo.io">https://hexo.io</a>`. | ||
## Extras | ||
### Definition/Description Lists | ||
`hexo-renderer-marked` also implements description/definition lists using the same syntax as [PHP Markdown Extra][PHP Markdown Extra]. | ||
This Markdown: | ||
```markdown | ||
Definition Term | ||
: This is the definition for the term | ||
``` | ||
will generate this html: | ||
```html | ||
<dl> | ||
<dt>Definition Term</dt> | ||
<dd>This is the definition for the term</dd> | ||
</dl> | ||
``` | ||
Note: There is currently a limitation in this implementation. If multiple definitions are provided, the rendered HTML will be incorrect. | ||
For example, this Markdown: | ||
```markdown | ||
Definition Term | ||
: Definition 1 | ||
: Definition 2 | ||
``` | ||
will generate this HTML: | ||
```html | ||
<dl> | ||
<dt>Definition Term<br>: Definition 1</dt> | ||
<dd>Definition 2</dd> | ||
</dl> | ||
``` | ||
If you've got ideas on how to support multiple definitions, please provide a pull request. We'd love to support it. | ||
[Markdown]: https://daringfireball.net/projects/markdown/ | ||
[marked]: https://github.com/chjj/marked | ||
[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/#def-list |
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
3
6
106
1
91
0
9637
8
+ Addedmarked@0.6.3(transitive)
- Removedobject-assign@^4.1.1
- Removedmarked@0.3.19(transitive)
- Removedobject-assign@4.1.1(transitive)
Updatedmarked@^0.6.1