控制容器中的自动换行
我有一个特殊的问题。我有一个电子邮件组,通过管道将电子邮件发送到留言板。电子邮件的换行方式各不相同。在雅虎,消息往往会填满留言板上的整个容器。但在所有其他邮件客户端中,只有部分容器宽度被填充,因为原始邮件已被包装。我希望所有电子邮件填充容器的整个宽度。我想到了两种可能的解决方案:CSS 或消除换行符的正则表达式。因为我只是一名车库机械师(从事此类工作),所以我根本无法完成这项工作。有什么帮助吗?
以下是显示问题的链接: http://seanwilson.org/forum/index.php?t=msg&th=1729&start=0&S=171399e41f2c10c4357dd9b217caaa3f (将“sean”的消息与“rob”的消息进行比较。一个填满了容器,另一个则没有)。
你们中有人能建议如何让所有邮件填满容器吗?
I have a peculiar problem. I have an email group that pipes emails to a message board. The word wrap of the emails varies. In yahoo, the messages tend to fill the entire container on the message board. But in all other mail clients, only part of the container width is filled, because the original mail was wrapped. I want all of the email messages to fill the entire width of the container. I've thought of two possible solutions: CSS, or a Regex that eliminates line breaks. Because I am only a garage mechanic (at these sorts of things), I simply cannot get the job done. Any help out there?
Here is a link that shows the issue: http://seanwilson.org/forum/index.php?t=msg&th=1729&start=0&S=171399e41f2c10c4357dd9b217caaa3f
(compare the message of "sean" with that of "rob." One fills the container, the other not).
Can any of you suggest how to get all the mail to fill the container?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您提供的信息太少 - 您使用什么编程语言 - PHP/Javascript/有什么不同吗?
我认为你只需要用空格替换 \n、\r 和 \r\n 即可。 PHP 代码:
您可以在其他语言中进行类似的操作(对于 JS,请参阅 string.replace 方法: http://www.tizag.com/javascriptT/javascript-string-replace.php)。
You gave too little information - what programming language are you using - PHP/Javascript/anything different?
I think you only need to replace \n, \r and \r\n with whitespace. PHP code for that:
You can do that analogically in other languages (for JS see string.replace method: http://www.tizag.com/javascriptT/javascript-string-replace.php).
根据具体情况(人们似乎总是在段落之间添加 2 个换行符),您可以说问题是:用空格替换所有不直接在换行符之前或之后的换行符。
在允许 \r 的同时:
编辑:没关系:不要使用:虽然人们倾向于在段落中编写电子邮件文本,但您将使用此正则表达式破坏他们的签名/签收。人们可以在认为它“可破坏”之前摆弄最小行长(我选择了 63),但它会很繁琐:
问题是:无法保证换行不是故意的。通过可调整的行长度,您可以将其基于普通用户,但问题是:他们更介意什么:破坏和破坏之间的差异?不间断的段落,还是破坏他们的签名?
Depending on the situation (people always seem to add 2 linebreaks between paragraphs), you could say the problem is: replace all newlines not directly preceded or followed by a newline with a space.
While allowing \r's:
Edit: nevermind: do not use: while people tend to write their email text in paragraphs, you will break their signature / signoff with this regex. One could fiddle around with a minimum linelength before deeming it 'breakable' (i chose 63), but fiddly it will be:
The problem is: there are no assurance the linebreak wasn't intended. With a fiddleable line-length you could base it on average users, but the question is: what do they mind more: the differences between breaking & non-breaking paragraphs, or the breaking of their signatures?
谢谢你这么快就回来了!
讨论板使用 php(以及 CSS)。唯一的麻烦是我修改其编程的能力有些有限。如果我要以我目前的技术水平做到这一点,我只有两个选择之一。
如果我不删除 \r,Wrikken 的解决方案会起作用吗?因为这似乎是正确的。 (可以将 \r 添加到 preg-replace 中吗?)
非常感谢您的帮助!
[注:非常感谢您的帮助!解决方案有效!我把数字改为53左右。它需要小一点。我不在乎罕见的长签名行可能会丢失回车符。对于一个完整的消息框来说,这是一个很小的代价!你轻松地让我节省了几天的学习时间,这些东西注定会令人沮丧,非常感谢你的快速解决。我很高兴在这里收到的帮助。]
Thanks for getting back so quickly!
The discussion board uses php (and also CSS). The only trouble is that I am somewhat limited in my ability to tinker with its programing. If I am to do this at my current level of skilty, I have only one of two options.
Would Wrikken's solution work if I do not remove \r's? Because that seems to be spot on. (could the \r's be added to the preg-replace?)
Thanks so much for your help!
[NOTE: thanks so much for your help! The solution worked!!! I changed the number to 53 or so. It needed to be a little smaller. I don't care that a rare, long signature lines may lose its carriage return. That's a small price to pay for a full message box! You easily saved me several days of learning something that was bound to be moderately frustrating, Thanks so much for that quick fix. I am joyous at the help I received here.]