File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 3
3
4
4
/*
5
5
* Add Link button next to a heading
6
+ * based on https://github.com/hexojs/hexo-renderer-marked/blob/master/lib/renderer.js
6
7
*/
7
8
8
- const { slugize, stripHTML } = require ( 'hexo-util' )
9
+ const { slugize, stripHTML, unescapeHTML : unescape } = require ( 'hexo-util' )
9
10
10
11
const anchorId = ( str , transformOption ) => {
11
- return slugize ( str . trim ( ) , { transform : transformOption } )
12
+ return slugize ( stripHTML ( unescape ( str ) ) . trim ( ) , { transform : transformOption } ) ;
12
13
}
13
14
14
15
hexo . extend . filter . register ( 'marked:renderer' , function ( renderer ) {
15
16
const { config } = this
16
17
renderer . heading = function ( text , level ) {
17
- const transformOption = config . marked . modifyAnchors
18
- let id = anchorId ( stripHTML ( text ) , transformOption )
19
- const headingId = this . _headingId
18
+ const { modifyAnchors } = config . marked
19
+ const transformOption = modifyAnchors ;
20
+ let id = anchorId ( text , transformOption )
21
+ const headingId = { } ;
20
22
21
23
// Add a number after id if repeated
22
24
if ( headingId [ id ] ) {
You can’t perform that action at this time.
0 commit comments