duanliaozhi2915
2014-12-22 15:07
浏览 340
已采纳

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

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. 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.

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.

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. How to fix it?

图片转代码服务由CSDN问答提供 功能建议

我在我的WordPress博客中共享代码,但我不想使用任何插件或第三方来托管和 格式化我的代码。 我添加代码并在其周围使用&lt; pre&gt;&lt; / pre&gt; 标签,但问题是当有人复制它时,所有换行符都会消失,粘贴的代码会变成一行,有时会混淆 用户或一段时间停止工作。

所以现在有任何技巧可以在每一行的末尾添加换行符或&lt; br /&gt; 代码>&lt; pre&gt;&lt; / pre&gt; 标记仅使用PHP或JavaScript。

您可以在此处看到DEMO的错误... \ n

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题