Commit 26a833cd authored by 徐一鸣's avatar 徐一鸣

文档内容

parent 54cf57fb
......@@ -87,22 +87,22 @@ export default {
pre_h2_index = 0;
pre_h3_index = 0;
level = 1;
id = `nav_${pre_h1_index}` + "_" + time;
id = `nav_${pre_h1_index}_${time}`;
newTitle = title.replace(/<h1/g, `<h1 id="${id}"`);
} else if (title.match(/<h2(([\s\S])*?)<\/h2>/g)) {
pre_h2_index++;
pre_h3_index = 0;
level = 2;
id = `nav_${pre_h1_index}_${pre_h2_index}` + "_" + time;
id = `nav_${pre_h1_index}_${pre_h2_index}_${time}`;
newTitle = title.replace(/<h2/g, `<h2 id="${id}"`);
} else if (title.match(/<h3(([\s\S])*?)<\/h3>/g)) {
pre_h3_index++;
level = 3;
id = `nav_${pre_h1_index}_${pre_h2_index}_${pre_h3_index}`;
id = `nav_${pre_h1_index}_${pre_h2_index}_${pre_h3_index}_${time}`;
newTitle = title.replace(/<h3/g, `<h3 id="${id}"`) + "_" + time;
newTitle = title.replace(/<h3/g, `<h3 id="${id}"`);
}
content = content.replace(new RegExp(title), newTitle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment