how to render post with doubled brackets in codeblock? #5303
-
when you put double brackets let { content = '' } = await hexo.post.render(null, {
content: markdownString,
// disableNunjucks: true,
engine: 'md'
});
## below is pretext
`build-${{ hashFiles('package-lock.json') }}` error occurs
also tried ## below is pretext
inline codeblock `build-${{ hashFiles('package-lock.json') }}`
```js
const varx = `build-${{ hashFiles('package-lock.json') }}`
```
when I enable option screenshotswithout with another testconst Hexo = require('../dist/hexo');
const hexo = new Hexo(__dirname, { silent: true })
const main = async () => {
await hexo.init();
const content = `
## below is pretext
inline codeblock \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`js
const varx = \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`
\`\`\`ts
const xvar = \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`
\`\`\`
const var = \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`
## below is meta info
- published: {{ page.date }}
- modified: {{ page.updated }}
`
const data = await hexo.post.render(null, {
content,
engine: 'markdown',
page: { date: '', updated: '' }
});
console.log(data.content.trim())
}
main() |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
@SukkaW @yoshinorin is this bug? |
Beta Was this translation helpful? Give feedback.
-
I think it is a same issue. |
Beta Was this translation helpful? Give feedback.
-
this caused by inline codeblock not escaped |
Beta Was this translation helpful? Give feedback.
-
thanks @D-Sketon const Hexo = require('hexo');
const hexo = new Hexo(__dirname, { silent: true })
const main = async () => {
await hexo.loadPlugin('hexo-renderers');
await hexo.loadPlugin('hexo-shortcodes');
await hexo.init();
const content = `
## below is pretext
inline codeblock \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`js
const varx = \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`
\`\`\`ts
const xvar = \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`
\`\`\`
const var = \`build-\${{ hashFiles('package-lock.json') }}\`
\`\`\`
## below is meta info
- published: {{ page.date }}
- modified: {{ page.updated }}
`
const data = await hexo.post.render(null, {
content,
engine: 'md',
page: { date: 'date published', updated: 'date modified' }
});
console.log(data.content.trim())
}
main() |
Beta Was this translation helpful? Give feedback.
thanks @D-Sketon