hexojs / hexo-renderer-markdown-it

Markdown-it is a Markdown parser, done right. A faster and CommonMark compliant alternative for Hexo.
MIT License
340 stars 60 forks source link

feat: support renderInline #198

Closed coolzjy closed 1 year ago

coolzjy commented 1 year ago

Support render inline (Single line rendering, without paragraph wrap) which is useful when rendering text inside plugins and tags.

For instance, I would be able to render caption and content without p tag with inline: true option:

hexo.extend.tag.register(
  "figure",
  function ([caption], content) {
    return `<figure>${hexo.render.renderSync(
      {
        text: content,
        engine: "markdown",
      },
      {
        inline: true,
      }
    )}<figcaption>${hexo.render.renderSync(
      {
        text: caption,
        engine: "markdown",
      },
      {
        inline: true,
      }
    )}</figcaption></figure>`;
  },
  { ends: true }
);