Browse Source

Fixed Heading ids same

develop
pandao 6 years ago
parent
commit
79d1d57188
  1. 28
      editormd.amd.js
  2. 2
      editormd.amd.min.js
  3. 28
      editormd.js
  4. 2
      editormd.min.js
  5. 28
      src/editormd.js

28
editormd.amd.js

@ -3477,7 +3477,8 @@
flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
};
var _headingIds = [];
var settings = $.extend(defaults, options || {});
var marked = editormd.$marked;
var markedRenderer = new marked.Renderer();
@ -3644,7 +3645,8 @@
text = trim(text);
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var toc = {
text : text,
level : level,
@ -3654,6 +3656,14 @@
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
if (_headingIds.indexOf(id) >= 0) {
id += editormd.rand(100, 999999);
}
_headingIds.push(id);
toc.id = id;
markdownToC.push(toc);
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
@ -4562,7 +4572,19 @@
return eventType;
};
/**
* 获取指定区间的随机整数
*
* @return {Int} int 返回随机生成的整数
*/
editormd.rand = function (n, m) {
var c = m - n + 1;
return Math.floor(Math.random() * c + n);
};
/**
* 日期时间的格式化方法
* Datetime format method

2
editormd.amd.min.js

File diff suppressed because one or more lines are too long

28
editormd.js

@ -3407,7 +3407,8 @@
flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
};
var _headingIds = [];
var settings = $.extend(defaults, options || {});
var marked = editormd.$marked;
var markedRenderer = new marked.Renderer();
@ -3574,7 +3575,8 @@
text = trim(text);
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var toc = {
text : text,
level : level,
@ -3584,6 +3586,14 @@
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
if (_headingIds.indexOf(id) >= 0) {
id += editormd.rand(100, 999999);
}
_headingIds.push(id);
toc.id = id;
markdownToC.push(toc);
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
@ -4492,7 +4502,19 @@
return eventType;
};
/**
* 获取指定区间的随机整数
*
* @return {Int} int 返回随机生成的整数
*/
editormd.rand = function (n, m) {
var c = m - n + 1;
return Math.floor(Math.random() * c + n);
};
/**
* 日期时间的格式化方法
* Datetime format method

2
editormd.min.js

File diff suppressed because one or more lines are too long

28
src/editormd.js

@ -3395,7 +3395,8 @@
flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
};
var _headingIds = [];
var settings = $.extend(defaults, options || {});
var marked = editormd.$marked;
var markedRenderer = new marked.Renderer();
@ -3562,7 +3563,8 @@
text = trim(text);
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var toc = {
text : text,
level : level,
@ -3572,6 +3574,14 @@
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
if (_headingIds.indexOf(id) >= 0) {
id += editormd.rand(100, 999999);
}
_headingIds.push(id);
toc.id = id;
markdownToC.push(toc);
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
@ -4480,7 +4490,19 @@
return eventType;
};
/**
* 获取指定区间的随机整数
*
* @return {Int} int 返回随机生成的整数
*/
editormd.rand = function (n, m) {
var c = m - n + 1;
return Math.floor(Math.random() * c + n);
};
/**
* 日期时间的格式化方法
* Datetime format method

Loading…
Cancel
Save