开发者

what are the disadvantages of having tons of   entities?

I've been writing a source-to-display converter for a small project. Basically, it takes an input and transforms the input into an output that is displayable by the browser (thin开发者_Python百科k Wikipedia-like).

The idea is there, but it isn't like the MediaWiki style, nor is like the MarkDown style. It has a few innovations by itself. For example, when the user types in a chain of spaces, I would presume he wants the spaces preserved. Since html ignores spaces by default, I was thinking of converting these chain of spaces into respective  s (for example 3 spaces in a row converted to 1  )

So what happens is that I can foresee a possibility of a ton of   tags per post (and a single page may have multiple posts).

I've been hearing alot of anti-&nbsps in the web, but most of it boils down to readability headaches (in this case, the input is supplied by the user. if he decides to make his post unreadable he can do so with any of the other formatting actions supplied) or maintenance headaches (which in this case is not, since it's a converted output).

I'm wondering what are the disadvantages of having tons of   tags on a webpage?


You are rendering every space as  ?

Besides wasting so much bandwidth, this will not allow dynamic line breaking as "nbsp" means "*n*on *b*reaking *sp*ace". This will most probably cause much trouble.


If it's just being dumped to a client, it's just a matter of size, and if it's gzipped, it barely matters in terms of network traffic.

It'll slow down rendering, I'm sure, and take up DOM space, but whether or not that matters depends on stuff I don't know about your use case(s). You might be able to achieve the same result in other ways, too; not sure.


 s aren't tags, but are character entities like ©, <, >, etc.

I'd say that the disadvantages would be readability. When I see a word, I expect the spacing to be constant (unless it is in a block of justified text).

Can you show me a case where you'd need  s?


Have you considered trying to figure out what the user, by inserting those spaces, is really trying to achieve? Rather than the how (they want to insert the spaces), the what (if the spaces are at the beginning of a line, they want to indent the text in question).

An example of this is many programming sites convert 4 spaces at the start of a line to a pre+code block.

For your purposes, maybe it should be a <block> block.

The end goal being that of converting the spaces not to what the user (with their limited resources) intended to show up there but, rather, what they meant to convey with it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜