Hexo: Markdown string in tag?

Created on 18 Dec 2016  ·  1Comment  ·  Source: hexojs/hexo

How do I convert string content to markdown in a tag?

{% custom %}
Make text **markdown**
{% endcustom %}
hexo.extend.tag.register('custom', function(args, content) {
  // render content in markdown before return
  return '<blockquote>' + content + '</blockquote>';
}, {ends: true});

Right now the above returns:

<blockquote>Make text **markdown**</blockquote>

And I want it to return this:

<blockquote>Make text <strong>markdown</strong></blockquote>

Most helpful comment

I figured it out.

hexo.extend.tag.register('custom', function(args, content) {
  content = hexo.render.renderSync({text: content, engine: 'markdown'});

  return '<blockquote>' + content + '</blockquote>';
}, {ends: true});

>All comments

I figured it out.

hexo.extend.tag.register('custom', function(args, content) {
  content = hexo.render.renderSync({text: content, engine: 'markdown'});

  return '<blockquote>' + content + '</blockquote>';
}, {ends: true});
Was this page helpful?
0 / 5 - 0 ratings