marked icon indicating copy to clipboard operation
marked copied to clipboard

cannot generate ID for CJK characters in headings

Open mantou132 opened this issue 9 years ago • 4 comments

code: # 标题一
render result: <h1 id="-">标题一</h1>

mantou132 avatar Jan 03 '17 03:01 mantou132

I have the same problem,a lot of id="-"

ginuim avatar Jan 03 '17 10:01 ginuim

    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.

Jiang-Xuan avatar Jan 17 '17 09:01 Jiang-Xuan

https://github.com/chjj/marked/issues/919#issuecomment-325099458 this solution looks fine

xzysun avatar Jan 13 '18 09:01 xzysun

Closing as we are starting to really look at removing header ids from marked and improve ways for extenders to do this themselves.

joshbruce avatar Apr 13 '18 17:04 joshbruce