New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot render headings with ids? #40

Closed
pujiaxun opened this Issue Aug 12, 2016 · 10 comments

Comments

5 participants
@pujiaxun

pujiaxun commented Aug 12, 2016

This renderer cannot generate ids in headings because of Markdown-it plugin not implement it.
So I tried a solution
Just use a plugin markdown-it-named-headings

npm install markdown-it-named-headings --save

And then add one line to render it with this plugin.

parser.use(require('markdown-it-named-headings'))

Just like this.

'use strict';

module.exports = function (data, options) {
  var MdIt = require('markdown-it');
  var cfg = this.config.markdown;
  var opt = (cfg) ? cfg : 'default';
  var parser = (opt === 'default' || opt === 'commonmark' || opt === 'zero') ?
    new MdIt(opt) :
    new MdIt(opt.render);

  parser.use(require('markdown-it-named-headings'))

 if (opt.plugins) {
    parser = opt.plugins.reduce(function (parser, pugs) {
      return parser.use(require(pugs));
    }, parser);
  }

  if (opt.anchors) {
    parser = parser.use(require('./anchors'), opt.anchors);
  }

  return parser.render(data.text);
};

Could I make a PR for this?

@khiav223577

This comment has been minimized.

Show comment
Hide comment
@khiav223577

khiav223577 Aug 15, 2017

Thanks. It works!

khiav223577 commented Aug 15, 2017

Thanks. It works!

@onlyfly34

This comment has been minimized.

Show comment
Hide comment
@onlyfly34

onlyfly34 Sep 30, 2017

Is this merged into the project? I had the same issues and this works for me to add
parser.use(require('markdown-it-named-headings'))

onlyfly34 commented Sep 30, 2017

Is this merged into the project? I had the same issues and this works for me to add
parser.use(require('markdown-it-named-headings'))

@HanchengZhao

This comment has been minimized.

Show comment
Hide comment
@HanchengZhao

HanchengZhao Dec 13, 2017

Hi, I wonder what else do you need to do after adding this line? I still have the problem after doing that. Thanks

HanchengZhao commented Dec 13, 2017

Hi, I wonder what else do you need to do after adding this line? I still have the problem after doing that. Thanks

@pujiaxun

This comment has been minimized.

Show comment
Hide comment
@pujiaxun

pujiaxun Dec 13, 2017

pujiaxun commented Dec 13, 2017

@pujiaxun

This comment has been minimized.

Show comment
Hide comment
@pujiaxun

pujiaxun Dec 14, 2017

@HanchengZhao Maybe you can reference this issue. If it doesn't work, I cannot solve it neither.

pujiaxun/pujiaxun.github.io#1

pujiaxun commented Dec 14, 2017

@HanchengZhao Maybe you can reference this issue. If it doesn't work, I cannot solve it neither.

pujiaxun/pujiaxun.github.io#1

@HanchengZhao

This comment has been minimized.

Show comment
Hide comment
@HanchengZhao

HanchengZhao Dec 16, 2017

@pujiaxun Thanks for the comment. My issue actually has something to do with 'hexo-toc' package. For those who might have the same problem, check out YenYuHsuan/hexo-theme-beantech#11

HanchengZhao commented Dec 16, 2017

@pujiaxun Thanks for the comment. My issue actually has something to do with 'hexo-toc' package. For those who might have the same problem, check out YenYuHsuan/hexo-theme-beantech#11

@noraj

This comment has been minimized.

Show comment
Hide comment
@noraj

noraj May 10, 2018

hexo-renderer-markdown-it is not compatible with hexo-toc yet even if hexo-toc claims it.

See bubkoo/hexo-toc#20

noraj commented May 10, 2018

hexo-renderer-markdown-it is not compatible with hexo-toc yet even if hexo-toc claims it.

See bubkoo/hexo-toc#20

@noraj

This comment has been minimized.

Show comment
Hide comment
@noraj

noraj May 10, 2018

Is this issue still up to date or it can be closed ?

noraj commented May 10, 2018

Is this issue still up to date or it can be closed ?

@pujiaxun

This comment has been minimized.

Show comment
Hide comment
@pujiaxun

pujiaxun May 12, 2018

@noraj So you mean it's not a bug but a kind of feature or nonsupport? Feel free to close it if you want.

pujiaxun commented May 12, 2018

@noraj So you mean it's not a bug but a kind of feature or nonsupport? Feel free to close it if you want.

@noraj

This comment has been minimized.

Show comment
Hide comment
@noraj

noraj May 13, 2018

@pujiaxun hexo-renderer-markdown-it works perfectly, it's hexo-toc that is a mess.

noraj commented May 13, 2018

@pujiaxun hexo-renderer-markdown-it works perfectly, it's hexo-toc that is a mess.

@pujiaxun pujiaxun closed this May 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment