1
1
'use strict' ;
2
2
3
- var should = require ( 'chai' ) . should ( ) ; // eslint-disable-line
4
- var util = require ( 'hexo-util' ) ;
3
+ const should = require ( 'chai' ) . should ( ) ; // eslint-disable-line
4
+ const util = require ( 'hexo-util' ) ;
5
5
6
- describe ( 'Marked renderer' , function ( ) {
7
- var ctx = {
6
+ describe ( 'Marked renderer' , ( ) => {
7
+ const ctx = {
8
8
config : {
9
9
marked : { }
10
10
}
11
11
} ;
12
12
13
- var r = require ( '../lib/renderer' ) . bind ( ctx ) ;
13
+ const r = require ( '../lib/renderer' ) . bind ( ctx ) ;
14
14
15
- it ( 'default' , function ( ) {
16
- var code = 'console.log("Hello world");' ;
15
+ it ( 'default' , ( ) => {
16
+ const code = 'console.log("Hello world");' ;
17
17
18
- var body = [
18
+ const body = [
19
19
'# Hello world' ,
20
20
'' ,
21
21
'```' ,
@@ -27,7 +27,7 @@ describe('Marked renderer', function() {
27
27
'hello'
28
28
] . join ( '\n' ) ;
29
29
30
- var result = r ( { text : body } ) ;
30
+ const result = r ( { text : body } ) ;
31
31
32
32
result . should . eql ( [
33
33
'<h1 id="Hello-world"><a href="#Hello-world" class="headerlink" title="Hello world"></a>Hello world</h1>' ,
@@ -37,86 +37,86 @@ describe('Marked renderer', function() {
37
37
] . join ( '' ) + '\n' ) ;
38
38
} ) ;
39
39
40
- it ( 'should render headings with links' , function ( ) {
41
- var body = [
40
+ it ( 'should render headings with links' , ( ) => {
41
+ const body = [
42
42
'## [hexo-server]' ,
43
43
'' ,
44
44
'[hexo-server]: https://github.com/hexojs/hexo-server'
45
45
] . join ( '\n' ) ;
46
46
47
- var result = r ( { text : body } ) ;
47
+ const result = r ( { text : body } ) ;
48
48
49
49
result . should . eql ( [
50
50
'<h2 id="hexo-server"><a href="#hexo-server" class="headerlink" title="hexo-server"></a>' ,
51
51
'<a href="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/hexojs/hexo-server">hexo-server</a></h2>'
52
52
] . join ( '' ) ) ;
53
53
} ) ;
54
54
55
- it ( 'should handle chinese headers properly' , function ( ) {
56
- var body = '# 中文' ;
57
- var result = r ( { text : body } ) ;
55
+ it ( 'should handle chinese headers properly' , ( ) => {
56
+ const body = '# 中文' ;
57
+ const result = r ( { text : body } ) ;
58
58
59
59
result . should . eql ( '<h1 id="中文"><a href="#中文" class="headerlink" title="中文"></a>中文</h1>' ) ;
60
60
} ) ;
61
61
62
62
// Description List tests
63
63
64
- it ( 'should render description lists with a single space after the colon' , function ( ) {
65
- var result = r ( { text : 'Description Term<br>: This is the Description' } ) ;
64
+ it ( 'should render description lists with a single space after the colon' , ( ) => {
65
+ const result = r ( { text : 'Description Term<br>: This is the Description' } ) ;
66
66
result . should . eql ( '<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>' ) ;
67
67
} ) ;
68
68
69
- it ( 'should render description lists with multiple spaces after the colon' , function ( ) {
70
- var result = r ( { text : 'Description Term<br>: This is the Description' } ) ;
69
+ it ( 'should render description lists with multiple spaces after the colon' , ( ) => {
70
+ const result = r ( { text : 'Description Term<br>: This is the Description' } ) ;
71
71
result . should . eql ( '<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>' ) ;
72
72
} ) ;
73
73
74
- it ( 'should render description lists with a tab after the colon' , function ( ) {
75
- var result = r ( { text : 'Description Term<br>: This is the Description' } ) ;
74
+ it ( 'should render description lists with a tab after the colon' , ( ) => {
75
+ const result = r ( { text : 'Description Term<br>: This is the Description' } ) ;
76
76
result . should . eql ( '<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>' ) ;
77
77
} ) ;
78
78
79
- it ( 'should render description lists with a carriage return after the colon' , function ( ) {
80
- var result = r ( { text : 'Description Term<br>:\nThis is the Description' } ) ;
79
+ it ( 'should render description lists with a carriage return after the colon' , ( ) => {
80
+ const result = r ( { text : 'Description Term<br>:\nThis is the Description' } ) ;
81
81
result . should . eql ( '<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>' ) ;
82
82
} ) ;
83
83
84
- it ( 'should not render regular paragraphs as description lists' , function ( ) {
85
- var result = r ( { text : 'Description Term<br>:This is the Description' } ) ;
84
+ it ( 'should not render regular paragraphs as description lists' , ( ) => {
85
+ const result = r ( { text : 'Description Term<br>:This is the Description' } ) ;
86
86
result . should . eql ( '<p>Description Term<br>:This is the Description</p>\n' ) ;
87
87
} ) ;
88
88
89
- describe ( 'autolink option tests' , function ( ) {
90
- var ctx = {
89
+ describe ( 'autolink option tests' , ( ) => {
90
+ const ctx = {
91
91
config : {
92
92
marked : {
93
93
autolink : true
94
94
}
95
95
}
96
96
} ;
97
97
98
- var renderer = require ( '../lib/renderer' ) ;
98
+ const renderer = require ( '../lib/renderer' ) ;
99
99
100
- var body = [
100
+ const body = [
101
101
'Great website http://hexo.io' ,
102
102
'' ,
103
103
'[Hexo](http://hexo.io)'
104
104
] . join ( '\n' ) ;
105
105
106
- it ( 'autolink enabled' , function ( ) {
107
- var r = renderer . bind ( ctx ) ;
108
- var result = r ( { text : body } ) ;
106
+ it ( 'autolink enabled' , ( ) => {
107
+ const r = renderer . bind ( ctx ) ;
108
+ const result = r ( { text : body } ) ;
109
109
110
110
result . should . eql ( [
111
111
'<p>Great website <a href="http://hexo.io">http://hexo.io</a></p>\n' ,
112
112
'<p><a href="http://hexo.io">Hexo</a></p>\n'
113
113
] . join ( '' ) ) ;
114
114
} ) ;
115
115
116
- it ( 'autolink disabled' , function ( ) {
116
+ it ( 'autolink disabled' , ( ) => {
117
117
ctx . config . marked . autolink = false ;
118
- var r = renderer . bind ( ctx ) ;
119
- var result = r ( { text : body } ) ;
118
+ const r = renderer . bind ( ctx ) ;
119
+ const result = r ( { text : body } ) ;
120
120
121
121
result . should . eql ( [
122
122
'<p>Great website http://hexo.io</p>\n' ,
@@ -125,26 +125,26 @@ describe('Marked renderer', function() {
125
125
} ) ;
126
126
} ) ;
127
127
128
- describe ( 'modifyAnchors option tests' , function ( ) {
129
- var body = [
128
+ describe ( 'modifyAnchors option tests' , ( ) => {
129
+ const body = [
130
130
'- [Example](#example)' ,
131
131
'' ,
132
132
'# Example'
133
133
] . join ( '\n' ) ;
134
134
135
- var renderer = require ( '../lib/renderer' ) ;
135
+ const renderer = require ( '../lib/renderer' ) ;
136
136
137
- var ctx = {
137
+ const ctx = {
138
138
config : {
139
139
marked : {
140
140
modifyAnchors : ''
141
141
}
142
142
}
143
143
} ;
144
144
145
- it ( 'should not modify anchors with default options' , function ( ) {
146
- var r = renderer . bind ( ctx ) ;
147
- var result = r ( { text : body } ) ;
145
+ it ( 'should not modify anchors with default options' , ( ) => {
146
+ const r = renderer . bind ( ctx ) ;
147
+ const result = r ( { text : body } ) ;
148
148
149
149
result . should . eql ( [
150
150
'<ul>' ,
@@ -154,10 +154,10 @@ describe('Marked renderer', function() {
154
154
] . join ( '\n' ) ) ;
155
155
} ) ;
156
156
157
- it ( 'should set anchors to upperCase in case of modifyAnchors option is 2' , function ( ) {
157
+ it ( 'should set anchors to upperCase in case of modifyAnchors option is 2' , ( ) => {
158
158
ctx . config . marked . modifyAnchors = 2 ;
159
- var r = renderer . bind ( ctx ) ;
160
- var result = r ( { text : body } ) ;
159
+ const r = renderer . bind ( ctx ) ;
160
+ const result = r ( { text : body } ) ;
161
161
162
162
result . should . eql ( [
163
163
'<ul>' ,
@@ -167,10 +167,10 @@ describe('Marked renderer', function() {
167
167
] . join ( '\n' ) ) ;
168
168
} ) ;
169
169
170
- it ( 'should set anchors to lowerCase in case of modifyAnchors option is 1' , function ( ) {
170
+ it ( 'should set anchors to lowerCase in case of modifyAnchors option is 1' , ( ) => {
171
171
ctx . config . marked . modifyAnchors = 1 ;
172
- var r = renderer . bind ( ctx ) ;
173
- var result = r ( { text : body } ) ;
172
+ const r = renderer . bind ( ctx ) ;
173
+ const result = r ( { text : body } ) ;
174
174
175
175
result . should . eql ( [
176
176
'<ul>' ,
0 commit comments