gpt4 book ai didi

html - 删除 HTML 电子邮件中 ​​
 标记内的空格

转载 作者:太空宇宙 更新时间:2023-11-03 19:29:28 26 4
gpt4 key购买 nike

我有一个使用 velocity 生成 HTML 电子邮件的应用程序。一个表达式生成我无法控制的输出(它来自 Jira 插件):

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<pre>#changesIncludingStatus([])</pre>
</td>
</tr>
</table>

输出包含换行符,但没有换行符。我正在尝试使用 pre 解决此问题。但出于某种原因,这些行还用空格标识,这在 HTML 电子邮件中看起来很奇怪。

<pre><div class="aptis-pre">            Bearbeiter: Vorgesetzter Mitarbeiter  (war: Administrator)
Resturlaub: 23
Beschreibung:
</div></pre>

结果 a strange display

有什么方法可以去掉每行开头的空格吗?

最佳答案

如果我对你的理解正确,你想要做的是保留换行符但折叠空格。

有一个 CSS 属性可以控制这种行为:white-space .如果设置为 pre-line它会完全做到这一点,来自 MDN :

pre-line: sequences of whitespace are collapsed. Lines are broken at newline characters, at <br>, and as necessary to fill line boxes.

.aptis-pre
{
white-space: pre-line;
}
<div class="aptis-pre">            Bearbeiter: Vorgesetzter Mitarbeiter  (war: Administrator)
Resturlaub: 23
Beschreibung:
</div>

请注意,因为您直接控制 white-space那么你不需要将该片段包装到 <pre> 中(将 white-space 设置为 pre 并保留空格)。

关于html - 删除 HTML 电子邮件中 ​​<pre> 标记内的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37294722/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com