bleach clean 在开头添加“<pre><code>”标签而不是清洗

bleach clean adds "<pre><code>“ tag at the beginning rather than cleaning

我从网上抓取了一些html内容,下面只是其中的一部分,

<p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;text-align: center;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;letter-spacing: 0.544px;font-size: 24px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(255, 41, 65);box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;letter-spacing: 0.544px;color: rgb(0, 0, 0);font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 24px;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;color: rgb(61, 167, 66);box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">...

我正在使用

body_html=bleach.clean(markdown(value, output_format='html'),tags=['SOME_ALLOWED_TAGS'] ,attributes=['SOME_ALLOWED_ATTRIBUTES'],styles=['SOME_ALLOWED_STYLES'],strip=True,strip_comments=True)

但是 return 不是我所期望的,

<pre><code> &lt;p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;text-align: center;box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;strong style="max-width: 100%;letter-spacing: 0.544px;font-size: 24px;box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;strong style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;span style="max-width: 100%;color: rgb(255, 41, 65);box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;strong style="max-width: 100%;letter-spacing: 0.544px;color: rgb(0, 0, 0);font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;span style="max-width: 100%;font-size: 24px;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;strong style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"&gt;&lt;span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box  

漂白剂清洁有什么问题?是不是因为我要清理的标签和样式太多所以只是在开头加了“<pre><code>”,在结尾处关闭了?

想通了。因为要清理的内容开头有\n \n\n \n\n \n \n。应该先删除那些。