Markdown输出HTML

模块a-markdown提供了bean组件markdown,只需一行代码即可将前端提交的Markdown内容输出为HTML

src/module-vendor/test-note/backend/src/bean/atom.note.js

  1. 1 async _renderContent({ item, atomId }) {
  2. 2 return await this.ctx.bean.markdown.render({
  3. 3 host: {
  4. 4 atom: item,
  5. 5 atomId,
  6. 6 },
  7. 7 content: item.content,
  8. 8 locale: this.ctx.locale,
  9. 9 });
  10. 10 }
  • 返回值:HTML字符串

  • 参数

名称 说明
host 宿主参数,由Markdown内容元素自行决定如何使用。如果是原子类型,一般要传递atomatomId
content markdown内容
locale 语言配置