redbug312 / markdown-it-multimd-table

Multimarkdown table syntax plugin for markdown-it markdown parser
MIT License
146 stars 37 forks source link

[Feature Request] Add option to customize id generation rule #33

Open OpportunityLiu opened 4 years ago

OpportunityLiu commented 4 years ago

https://github.com/RedBug312/markdown-it-multimd-table/blob/2570107cbf7c595057156cece284f1c8e468d40b/index.js#L61

This rule makes all title with no ascii alphabets to have an empty id, which makes it hard to refrence them.

For example 图片

OpportunityLiu commented 4 years ago

In markdown-it-anchor, such option named slugify.

redbug312 commented 4 years ago

Thanks for the report. I was waiting for upstream updates for consistent slugify implementation. However it seems the issue still remains open for conflicts and compatibility problems.

Option slugify can be configured now in branch customize-slugify. It'll be released as v4.1.0. Default one won't be replaced until v5.0.0, into this line in markdown-it-anchor (without incremented counters) Recommended to assign it to the option, for future compatibility.

const slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, '-'))