marked
marked copied to clipboard
cannot generate ID for CJK characters in headings
code: # 标题一
render result: <h1 id="-">标题一</h1>
I have the same problem,a lot of id="-"
Renderer.prototype.heading = function(text, level, raw) {
return '<h'
+ level
+ ' id="'
+ this.options.headerPrefix
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
};
raw.toLowerCase().replace(/[^\w]+/g, '-').
this line cause problem.
https://github.com/chjj/marked/issues/919#issuecomment-325099458 this solution looks fine
Closing as we are starting to really look at removing header ids from marked and improve ways for extenders to do this themselves.