lisongeee
2022-08-19 18:37:05 +08:00
测试 `tab` 缩进是否会被去掉
```ts
(() => {
const blankReg = /[\n\r]+/g;
Array.from(
document.querySelectorAll<HTMLElement>('div.reply_content')
).forEach((div) => {
const mdText = div.innerText;
const article = document.createElement('article');
article.classList.add('markdown-body');
article.innerHTML = 'markdownItInstance.render(mdText)';
if (
article.innerText.replace(blankReg, '') == mdText.replace(blankReg, '')
) {
// 渲染后无变化不执行替换
return;
}
article.style.width = '100%';
div.innerHTML = '';
div.classList.add('v2ex-comment-markdown');
div.appendChild(article);
});
})();
```