码迷,mamicode.com
首页 > Web开发 > 详细

htmlToTex

时间:2021-05-24 17:18:14      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:replace   img   图片   strong   div   ring   public   nbsp   pre   

public htmlToText(html: string) {
return html
.replace(/<br>/g, ‘‘)
.replace(/<p>/g, ‘‘)
.replace(/<\/p>/g, ‘‘)
.replace(/<\s*b[^>]*>/g, ‘‘)
.replace(/<\/\s*b[^>]*>/g, ‘‘)
.replace(/<\s*font[^>]*>/g, ‘‘)
.replace(/<\/\s*font[^>]*>/g, ‘‘)
.replace(/<\s*div[^>]*>/g, ‘‘)
.replace(/<\/\s*div[^>]*>/g, ‘‘)
.replace(/<\s*span[^>]*>/g, ‘‘)
.replace(/<\/\s*span[^>]*>/g, ‘‘)
.replace(/<\s*strong[^>]*>/g, ‘‘)
.replace(/<\/\s*strong[^>]*>/g, ‘‘)
.replace(/<\s*em[^>]*>/g, ‘‘)
.replace(/<\/\s*em[^>]*>/g, ‘‘)
.replace(/<\s*ul[^>]*>/g, ‘‘)
.replace(/<\/\s*ul[^>]*>/g, ‘‘)
.replace(/<\s*li[^>]*>/g, ‘‘)
.replace(/<\/\s*li[^>]*>/g, ‘‘)
.replace(/<\s*ol[^>]*>/g, ‘‘)
.replace(/<\/\s*ol[^>]*>/g, ‘‘)
.replace(/&nbsp;/g, ‘‘)
.replace(
/<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""‘]?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""‘<>]*)[^<>]*?>/g,
‘[图片]‘,
)
.replace(/<\s*a[^>]*>/g, ‘‘)
.replace(/<\/\s*a[^>]*>/g, ‘‘);
}

htmlToTex

标签:replace   img   图片   strong   div   ring   public   nbsp   pre   

原文地址:https://www.cnblogs.com/lhx5213/p/14791066.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!