Skip to content

Commit 23372e0

Browse files
committed
fix(highlight&prism): add 'caption' class
1 parent 1daa862 commit 23372e0

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/highlight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function highlightUtil(str, options = {}) {
4545
let codeCaption = '';
4646

4747
if (caption) {
48-
codeCaption = wrap ? `<figcaption>${caption}</figcaption>` : `<div>${caption}</div>`;
48+
codeCaption = wrap ? `<figcaption>${caption}</figcaption>` : `<div class="caption">${caption}</div>`;
4949
}
5050

5151
if (!wrap) {

lib/prism.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function PrismUtil(str, options = {}) {
9898

9999
if (tab) str = replaceTabs(str, tab);
100100

101-
const codeCaption = caption ? `<div>${caption}</div>` : '';
101+
const codeCaption = caption ? `<div class="caption">${caption}</div>` : '';
102102

103103
const startTag = `<pre class="${preTagClassArr.join(' ')}"${preTagAttr}>${codeCaption}<code class="language-${language}">`;
104104
const endTag = '</code></pre>';

test/highlight.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('highlight', () => {
218218

219219
result.should.eql([
220220
'<pre>',
221-
`<div>${caption}</div>`,
221+
`<div class="caption">${caption}</div>`,
222222
'<code class="highlight plain">',
223223
entities.encode(testString),
224224
'</code></pre>'

test/prism.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe('prismHighlight', () => {
330330
const caption = 'foo';
331331
const result = prismHighlight(input, { caption });
332332

333-
result.should.contains('<div>' + caption + '</div>');
333+
result.should.contains('<div class="caption">' + caption + '</div>');
334334

335335
validateHtmlAsync(result, done);
336336
});

0 commit comments

Comments
 (0)