Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
support images with caption (hugo)
Browse files Browse the repository at this point in the history
  • Loading branch information
titpetric committed Sep 8, 2017
1 parent cf8cd9c commit a3e3447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions front/src/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var markdown = {
},
transformHugo: function(contents, folder) {
contents = contents.replace(/{% asset_img ([^ ]+) %}/g, '![]($1)')
contents = contents.replace(/{% asset_img ([^ ]+) "(.+)" %}/g, '![$2]($1)')
contents = contents.replace(/{% asset_img ([^ ]+) '(.+)' %}/g, '![$2]($1)')
return contents
},
transformImages: function (contents, folder) {
Expand Down
8 changes: 7 additions & 1 deletion front/src/markdown/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ Adorable`
var content = '{% asset_img heading.jpg %} {% asset_img heading.jpg %}'
var expected = '![](/contents/test/heading.jpg) ![](/contents/test/heading.jpg)'
assert.equal(markdown.Transform(content, folder), expected)
})
})

it('should replace image with caption', function () {
var content = '{% asset_img heading.jpg "caption one" %} {% asset_img heading.jpg \'caption two\' %}'
var expected = '![caption one](/contents/test/heading.jpg) ![caption two](/contents/test/heading.jpg)'
assert.equal(markdown.Transform(content, folder), expected)
})

it('should replace pagebreak from hugo', function () {
var content = '<!--more--> <!--more-->'
Expand Down

0 comments on commit a3e3447

Please sign in to comment.