简体   繁体   English

如何添加 <br /> 在每一行的末尾 <pre> 标签?

[英]How To Add <br /> In The End Of Every Line In <pre> Tag?

I am sharing codes in my WordPress blog but I don't want to use any plugin or third party to host and format my codes. 我在WordPress博客中共享代码,但是我不想使用任何插件或第三方来托管和格式化我的代码。 I add codes and use <pre></pre> tags around it but the problem is that when someone copy it then all line break disappear and the pasted code becomes in one line that sometime confuse the user or some time stop working. 我添加了代码并在其周围使用了<pre></pre>标记,但是问题是,当有人复制它时,所有换行符都消失了,并且粘贴的代码变成了一行,这有时使用户感到困惑,或者有时会停止工作。

So now is there any trick to add line break or <br/> in the end of every line of <pre></pre> tag only using PHP or JavaScript. 因此,现在有什么技巧可以仅使用PHP或JavaScript在<pre></pre>标记的每一行末尾添加换行符或<br/>

You can see some error DEMO's here... 您可以在此处看到一些错误的演示...

and many more of my posts have this error. 我的更多帖子中都有此错误。

To check this error, Just copy the <pre></pre> tag codes and paste it anywhere and see that there will be no line break as code shows on blog. 要检查此错误,只需复制<pre></pre>标记代码并将其粘贴到任何地方,即可看到博客上的代码不会出现换行符。 How to fix it? 如何解决?

I think the problem in the script sharethis.com. 我认为脚本sharethis.com中存在问题。 Try disabling "Measure copy and shares of your website's content" in http://www.sharethis.com/get-sharing-tools/ 尝试在http://www.sharethis.com/get-sharing-tools/中禁用“衡量网站内容的副本和共享”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM