Как удалить блоки html?
Мне нужно удалить блок blockquote. Как я могу это сделать?
<blockquote class="gmail_quote" style="margin:0px 0px 0px .8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div style="line-height:18px;font-family:Arial, Helvetica, sans-serif;font-size:14px;color:rgb(0,0,0);">
....
....
</blockquote>
Я попробовал этот способ, но он мне не помог.
l_oResponse[key].message['content_html'] // Просто Html страничка
String(message_key).replace(/<blockquote[^>]*>.*<\/blockquote>/, "");
Ответы (1 шт):
Автор решения: oshliaer
→ Ссылка
Пусть в файле index.html будет разметка
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<blockquote cite="https://www.huxley.net/bnw/four.html">
<p>Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.</p>
<footer>—Aldous Huxley, <cite>Brave New World</cite></footer>
</blockquote>
<p><a href="https://www.huxley.net/bnw/four.html">Huxley's Quote</a></p>
<blockquote cite="https://www.huxley.net/bnw/four.html">
<p>Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.</p>
<footer>—Aldous Huxley, <cite>Brave New World</cite></footer>
</blockquote>
</body>
</html>
Тогда замена может быть такой
function myFunction() {
const content = HtmlService.createHtmlOutputFromFile('index').getContent();
const text = content.replace(/<blockquote[\s\S]+?\/blockquote>/gm, '');
console.log(text);
}
