Comparing version 2.3.0 to 2.4.0
@@ -33,3 +33,2 @@ 'use strict'; | ||
const figCaption = caption ? `<figcaption>${caption}</figcaption>` : ''; | ||
@@ -47,6 +46,12 @@ const lines = data.value.split('\n'); | ||
let codeCaption = ''; | ||
if (caption) { | ||
codeCaption = wrap ? `<figcaption>${caption}</figcaption>` : `<div class="caption">${caption}</div>`; | ||
} | ||
if (!wrap) { | ||
// if original content has one trailing newline, replace it only once, else remove all trailing newlines | ||
content = /\r?\n$/.test(data.value) ? content.replace(/\n$/, '') : content.trimEnd(); | ||
return `<pre>${figCaption}<code class="${classNames}">${content}</code></pre>`; | ||
return `<pre>${codeCaption}<code class="${classNames}">${content}</code></pre>`; | ||
} | ||
@@ -56,3 +61,3 @@ | ||
result += figCaption; | ||
result += codeCaption; | ||
@@ -59,0 +64,0 @@ result += '<table><tr>'; |
@@ -65,3 +65,4 @@ 'use strict'; | ||
firstLine, | ||
isPreprocess = true | ||
isPreprocess = true, | ||
caption | ||
} = options; | ||
@@ -101,3 +102,5 @@ | ||
const startTag = `<pre class="${preTagClassArr.join(' ')}"${preTagAttr}><code class="language-${language}">`; | ||
const codeCaption = caption ? `<div class="caption">${caption}</div>` : ''; | ||
const startTag = `<pre class="${preTagClassArr.join(' ')}"${preTagAttr}>${codeCaption}<code class="language-${language}">`; | ||
const endTag = '</code></pre>'; | ||
@@ -104,0 +107,0 @@ |
{ | ||
"name": "hexo-util", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Utilities for Hexo.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
@@ -454,2 +454,3 @@ # hexo-util | ||
`firstLine` | First line number | | ||
`caption` | Caption | | ||
@@ -456,0 +457,0 @@ When `isPreprocess` is enabled, `prismHighlight()` will return PrismJS processed HTML snippet. Otherwise `str` will only be escaped and `prismHighlight()` will return the HTML snippet that is suitable for `prism.js` working in the Browser. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80409
1341
750