修复h标签渲染包含图片锚点错误并图片渲染不了的问题
This commit is contained in:
parent
1727be1eaf
commit
282b546edc
@ -56,6 +56,7 @@ export default (md) => {
|
|||||||
|
|
||||||
// According to http://pandoc.org/README.html#extension-auto_identifiers
|
// According to http://pandoc.org/README.html#extension-auto_identifiers
|
||||||
let slug = headingContent
|
let slug = headingContent
|
||||||
|
.replace(/<img[^>]*>/g, '') // Replace image to empty
|
||||||
.replace(/\s/g, '-') // Replace all spaces and newlines with hyphens
|
.replace(/\s/g, '-') // Replace all spaces and newlines with hyphens
|
||||||
.replace(/[\0-,/:-@[-^`{-~]/g, '') // Remove all punctuation, except underscores, hyphens, and periods
|
.replace(/[\0-,/:-@[-^`{-~]/g, '') // Remove all punctuation, except underscores, hyphens, and periods
|
||||||
.toLowerCase(); // Convert all alphabetic characters to lowercase
|
.toLowerCase(); // Convert all alphabetic characters to lowercase
|
||||||
|
@ -233,7 +233,12 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
|
|||||||
const clonedElt = headingElt.cloneNode(true);
|
const clonedElt = headingElt.cloneNode(true);
|
||||||
clonedElt.removeAttribute('id');
|
clonedElt.removeAttribute('id');
|
||||||
sectionTocElt.appendChild(clonedElt);
|
sectionTocElt.appendChild(clonedElt);
|
||||||
headingElt.innerHTML = `<span class="prefix"></span><span class="content">${headingElt.innerHTML}</span><span class="suffix"></span>`;
|
const prefixElt = document.createElement('span');
|
||||||
|
prefixElt.className = 'prefix';
|
||||||
|
headingElt.insertBefore(prefixElt, headingElt.firstChild);
|
||||||
|
const suffixElt = document.createElement('span');
|
||||||
|
suffixElt.className = 'suffix';
|
||||||
|
headingElt.appendChild(suffixElt);
|
||||||
}
|
}
|
||||||
if (insertBeforeTocElt) {
|
if (insertBeforeTocElt) {
|
||||||
this.tocElt.insertBefore(sectionTocElt, insertBeforeTocElt);
|
this.tocElt.insertBefore(sectionTocElt, insertBeforeTocElt);
|
||||||
|
Loading…
Reference in New Issue
Block a user