Markdown输出HTML
模块a-markdown
提供了bean组件markdown
,只需一行代码即可将前端提交的Markdown内容输出为HTML
src/module-vendor/test-note/backend/src/bean/atom.note.js
- 1 async _renderContent({ item, atomId }) {
- 2 return await this.ctx.bean.markdown.render({
- 3 host: {
- 4 atom: item,
- 5 atomId,
- 6 },
- 7 content: item.content,
- 8 locale: this.ctx.locale,
- 9 });
- 10 }
-
返回值:HTML字符串
-
参数
名称 | 说明 |
---|---|
host | 宿主参数,由Markdown内容元素自行决定如何使用。如果是原子类型 ,一般要传递atom 和atomId |
content | markdown内容 |
locale | 语言配置 |
评论: