Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更正HTML文本换行_Html_Coldfusion_Word Wrap - Fatal编程技术网

如何更正HTML文本换行

如何更正HTML文本换行,html,coldfusion,word-wrap,Html,Coldfusion,Word Wrap,这是一个基本的html文本包装问题,但它让我感到困惑。我在后端使用coldfusion。我有以下模板: This line has 30 characters it This line has 40 characters it a b a b a This line has 50 characters it a b a b a as d f e This line has 60 characters it a b a b a as d f e we r t yy This line

这是一个基本的html文本包装问题,但它让我感到困惑。我在后端使用coldfusion。我有以下模板:

 This line has 30 characters it
 This line has 40 characters it a b a b a
 This line has 50 characters it a b a b a as d f e
 This line has 60 characters it a b a b a as d f e we r t yy 
 This line has 70 characters it a b a b a as d f e we r t yy e 4 r t 5 
我将模板加载到textarea中,让用户编辑它以生成如下报告:

 <textarea name="Report" cols="72" rows="40">#template#</textarea>

我对此绞尽脑汁,任何建议或评论都非常感谢。

我从未真正使用过
Wrap()
,但在ACF中,它看起来只是每隔72个字符插入一个中断符(Railo似乎很注意位置)

你有几个选择

最容易使用的解决方案是使用这样的替换来显示数据

#rereplace(variable,"([^\n]{1,71})[\s]","\1<br>","ALL")#

<cfsavecontent variable="seventytwo">abcdefghijklmnopqrstabcdefghijklmnopqrstabcdefghijklmnopqrst
 This line has 30 characters it
 This line has 40 characters it a b a b a
 This line has 50 characters it a b a b a as d f e
 This line has 60 characters it a b a b a as d f e we r t yy 
 This line has 70 characters it a b a b a as d f e we r t yy e 4 r t 5 
</cfsavecontent>

<pre><cfoutput>#wrap(seventytwo,72)#

#rereplace(seventytwo,"([^\n]{1,71})[\s]","\1<br>","ALL")#</cfoutput></pre>

<cfsavecontent variable="seventytwo">
Contrary to popular belief,
  Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</cfsavecontent>

<pre><cfoutput>#rereplace(seventytwo,"([^\n]{1,71})[\s]","\1<br>","ALL")#</cfoutput></pre>
与人们的普遍看法相反, Lorem Ipsum不是简单的随机文本。它起源于公元前45年的一段古典拉丁文学,距今已有2000多年的历史。弗吉尼亚州汉普顿悉尼学院的拉丁语教授理查德·麦克林托克(Richard McClintock)从《洛伦·伊普斯姆》(Lorem Ipsum)一段中查找了一个更为晦涩的拉丁语单词,即“Concertetur”,并查阅了古典文学中对该词的引用,发现了该词无可置疑的来源。Lorem Ipsum来自西塞罗于公元前45年所著《德菲尼布斯·博诺勒姆和马洛勒姆》(善与恶的极端)的第1.10.32节和第1.10.33节。这本书是一本关于伦理学理论的论文,在文艺复兴时期非常流行。Lorem Ipsum的第一行“Lorem Ipsum dolor sit amet..”来自第1.10.32节中的一行。 以下是自1500年代以来使用的Lorem Ipsum的标准块,供感兴趣的人参考。西塞罗的“de Finibus Bonorum et Malorum”中的第1.10.32节和第1.10.33节也以其原始形式复制,并附有H.Rackham 1914年翻译的英文版本。 #重新替换(第七十二个“([^\n]{1,71})[\s]”,“\1
”,“全部”)# 编辑:以上内容不包括72个以上不带空格的字符串。你可以用这样的东西


与人们的普遍看法相反,
Lorem Ipsum不是简单的随机文本。Cookies是最棒的,但它能让你变得肥胖,让你不喜欢被称为不含食物的曲奇。它起源于公元前45年的一篇古典拉丁文学作品,距今已有2000多年的历史。弗吉尼亚州汉普顿悉尼学院的拉丁语教授理查德·麦克林托克(Richard McClintock)从《洛伦·伊普斯姆》(Lorem Ipsum)一段中查找了一个更为晦涩的拉丁语单词,即“Concertetur”,并查阅了古典文学中对该词的引用,发现了该词无可置疑的来源。Lorem Ipsum来自西塞罗于公元前45年所著《德菲尼布斯·博诺勒姆和马洛勒姆》(善与恶的极端)的第1.10.32节和第1.10.33节。这本书是一本关于伦理学理论的论文,在文艺复兴时期非常流行。Lorem Ipsum的第一行“Lorem Ipsum dolor sit amet..”来自第1.10.32节中的一行。
以下是自1500年代以来使用的Lorem Ipsum的标准块,供感兴趣的人参考。西塞罗的“de Finibus Bonorum et Malorum”中的第1.10.32节和第1.10.33节也以其原始形式复制,并附有H.Rackham 1914年翻译的英文版本。
#重新替换(第七十二个“([^\n]{1,71})[\n]|([^\n]{1,71}”),“\1
”,“全部”)#
谢谢!我感谢你的帮助
 <CFSET #Report# = #wrap(#Report#, 72)#>
 This line has 30 characters it
 This line has 40 characters it a b
 a b a
 This line has 50 characters it a b a b a as d f e
 This line has
 60 characters it a b a b a as d f e we r t yy 
 This line has 70
 characters it a b a b a as d f e we r t yy e 4 r t 5 
#REReplace(variable,"(\r\n|\n\r|\r|\n)","<br>\1","ALL")#.
#rereplace(variable,"([^\n]{1,71})[\s]","\1<br>","ALL")#

<cfsavecontent variable="seventytwo">abcdefghijklmnopqrstabcdefghijklmnopqrstabcdefghijklmnopqrst
 This line has 30 characters it
 This line has 40 characters it a b a b a
 This line has 50 characters it a b a b a as d f e
 This line has 60 characters it a b a b a as d f e we r t yy 
 This line has 70 characters it a b a b a as d f e we r t yy e 4 r t 5 
</cfsavecontent>

<pre><cfoutput>#wrap(seventytwo,72)#

#rereplace(seventytwo,"([^\n]{1,71})[\s]","\1<br>","ALL")#</cfoutput></pre>

<cfsavecontent variable="seventytwo">
Contrary to popular belief,
  Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</cfsavecontent>

<pre><cfoutput>#rereplace(seventytwo,"([^\n]{1,71})[\s]","\1<br>","ALL")#</cfoutput></pre>
<cfsavecontent variable="seventytwo">
Contrary to popular belief,
  Lorem Ipsum is not simply random text. cookiesarethebestbuttheycanmakeyoufatandnoonelikesbeingcalledfatsodonteatlotsofcookies It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</cfsavecontent>

<pre><cfoutput>#rereplace(seventytwo,"(([^\n]{1,71})[\n ]|([^\n]{1,71}))","\1<br>","ALL")#</cfoutput></pre>