1
1
# hexo-renderer-marked
2
2
3
- [ ![ Build Status ] ( https://github.com/hexojs/hexo-renderer-marked/workflows/Tester /badge.svg?branch=master )] ( https://github.com/hexojs/hexo-renderer-marked/actions?query=workflow%3ATester )
3
+ [ ![ Tester ] ( https://github.com/hexojs/hexo-renderer-marked/actions/ workflows/tester.yml /badge.svg?branch=master )] ( https://github.com/hexojs/hexo-renderer-marked/actions/workflows/tester.yml )
4
4
[ ![ NPM version] ( https://badge.fury.io/js/hexo-renderer-marked.svg )] ( https://www.npmjs.com/package/hexo-renderer-marked )
5
5
[ ![ Coverage Status] ( https://img.shields.io/coveralls/hexojs/hexo-renderer-marked.svg )] ( https://coveralls.io/r/hexojs/hexo-renderer-marked?branch=master )
6
6
[ ![ NPM Dependencies] ( https://img.shields.io/librariesio/release/npm/hexo-renderer-marked.svg )] ( https://libraries.io/npm/hexo-renderer-marked )
@@ -20,7 +20,7 @@ There are two solutions to avoid those issues:
20
20
21
21
## Installation
22
22
23
- ``` bash
23
+ ``` bash
24
24
$ npm install hexo-renderer-marked --save
25
25
```
26
26
@@ -32,7 +32,7 @@ $ npm install hexo-renderer-marked --save
32
32
33
33
You can configure this plugin in ` _config.yml ` .
34
34
35
- ``` yaml
35
+ ``` yml
36
36
marked :
37
37
gfm : true
38
38
pedantic : false
@@ -83,7 +83,7 @@ marked:
83
83
- **figcaption** - Append `figcaption` element after each image.
84
84
- **prependRoot** - Prepend root value to (internal) image path.
85
85
* Example `_config.yml`:
86
- ` ` ` yml
86
+ ` ` ` yml
87
87
root: /blog/
88
88
` ` `
89
89
* `` becomes `<img src="/blog/path/to/image.jpg" alt="text">`
@@ -112,7 +112,7 @@ For more options, see [Marked](https://marked.js.org/using_advanced#options). Du
112
112
113
113
To enable it, pass an object containing the DOMPurify options :
114
114
115
- ` ` ` json
115
+ ` ` ` yml
116
116
dompurify: true
117
117
` ` `
118
118
@@ -173,10 +173,11 @@ This plugin overrides some default behaviours of how [marked] plugin renders the
173
173
174
174
For example, to override how heading like `# heading text` is rendered:
175
175
176
- ` ` ` js
176
+ ` ` ` js
177
177
hexo.extend.filter.register('marked:renderer', function(renderer) {
178
178
const { config } = this; // Skip this line if you don't need user config from _config.yml
179
- renderer.heading = function(text, level) {
179
+ renderer.heading = function({ tokens, depth: level }) {
180
+ const text = this.parser.parseInline(tokens);
180
181
// Default behaviour
181
182
// return ` <h${level}>${text}</h${level}>`;
182
183
// outputs <h1>heading text</h1>
@@ -196,7 +197,7 @@ Notice `renderer.heading = function (text, level) {` corresponds to [this line](
196
197
197
198
It is also possible to customize the [ tokenizer] ( https://marked.js.org/using_pro#tokenizer ) .
198
199
199
- ``` js
200
+ ``` js
200
201
const { escapeHTML: escape } = require (' hexo-util' );
201
202
202
203
// https://github.com/markedjs/marked/blob/b6773fca412c339e0cedd56b63f9fa1583cfd372/src/Lexer.js#L8-L24
0 commit comments