File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ function images(md, opts) {
13
13
const token = tokens [ idx ] ;
14
14
const { postPath } = env ;
15
15
16
+ token . attrSet ( 'alt' , token . content ) ;
17
+
16
18
if ( lazyload ) {
17
19
token . attrSet ( 'loading' , 'lazy' ) ;
18
20
}
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ describe('Hexo Renderer Markdown-it', () => {
118
118
const resultInline = renderer . render ( { text } , { inline : true } ) ;
119
119
resultBlock . should . eql ( '<p>inline text</p>\n' ) ;
120
120
resultInline . should . eql ( 'inline text' ) ;
121
- } )
121
+ } ) ;
122
122
} ) ;
123
123
124
124
describe ( 'plugins' , ( ) => {
@@ -403,6 +403,15 @@ describe('Hexo Renderer Markdown-it', () => {
403
403
result . should . eql ( '<p><img src="/blog/bar/baz.jpg" alt=""></p>\n' ) ;
404
404
} ) ;
405
405
406
+ it ( 'alt text' , ( ) => {
407
+ hexo . config . markdown . images = { test : true } ;
408
+
409
+ const renderer = new Renderer ( hexo ) ;
410
+ const result = renderer . render ( { text : '' } ) ;
411
+
412
+ result . should . eql ( '<p><img src="/bar/baz.jpg" alt="alt text"></p>\n' ) ;
413
+ } ) ;
414
+
406
415
describe ( 'post_asset' , ( ) => {
407
416
const Post = hexo . model ( 'Post' ) ;
408
417
const PostAsset = hexo . model ( 'PostAsset' ) ;
You can’t perform that action at this time.
0 commit comments