渲染HTML中的制表符 [英] Render tab characters in HTML

查看:244
本文介绍了渲染HTML中的制表符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将一些文本呈现到网页上.文本来自我无法控制的来源,并且使用换行符和制表符设置了格式.

I have to render some text to a web page. The text is coming from sources outside my control and it is formatted using newlines and tab characters.

换行(\n)可以用br标记代替,但是保留制表符又如何呢?简短的搜索显示无法直接用HTML呈现制表符.

New lines (\n) can be replaced by br tags, but what about preserving tabs? A brief search reveals there is no way to directly render tab characters in HTML.

推荐答案

replace \t with      

您想要的每个空间都是 

Each space you want will be a  

正如所指出的那样,这并不完全正确,因为它只是假装为制表符,因为HTML并没有像您期望的那样实际输出制表符的格式.

As pointed out this isn't the completely correct as it only pretends to be a tab as HTML doesn't actually output format a tab as you would expect.

这篇关于渲染HTML中的制表符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆