HTML tags optimization

D

DENG

hi all,

i want to do some optimizations for HTML tags,

something like this:

<i><b>TEXT1</b></i><b><i><u>TEXT2</u></i></b>

optimise to

<i><b>TEXT1<u>TEXT2</u></b><i>

at the very beginning, i was thinking of analysing each text-block, to
know their color, size, if is bold or italic, but i found it was too
complicated.

e.g

<font color=red><font size=6>TEXT1</font></font>

optimise to

<font color=red size=6>TEXT1</font>

but if there is TEXT2 exist

<font color=red><font size=6>TEXT1</font>TEXT2</font>

we can not do any optimization.

my problem is I can not find a method to treat all those situation, I
had too much thinking and get fool now

anyone can give me some advices?

thanks

PS:

other examples:

1
<font size=5><font size=7>TEXT</font></font>
=>
<font size=7>TEXT</font>

2
<i>TEXT </i><i>TEXT</i>
=>
<i>TEXT TEXT</i>

3
<i>TEXT<i>TEXT</i></i>
=>
<i>TEXT</i>

etc...
 
S

Steve Holden

DENG said:
hi all,

i want to do some optimizations for HTML tags,

something like this:

<i><b>TEXT1</b></i><b><i><u>TEXT2</u></i></b>

optimise to

<i><b>TEXT1<u>TEXT2</u></b><i>

at the very beginning, i was thinking of analysing each text-block, to
know their color, size, if is bold or italic, but i found it was too
complicated.
[etc ...]

Are you expecting the answers to be different that they were two days ago?

regards
Steve
 
B

bruno modulix

DENG wrote:
(snip same post as two days ago)

<ot>
In case you don't know, google.groups is just a web interface (and
archive) to usenet groups. No need to repost the same question twice...
</ot>

BTW, for what you want to do (which is mostly a waste of time IMHO, but
what, that's your time, not mine), the obvious, CS101 answer is to first
build an AST of your document, then transform this AST - collapsing
nodes when possible etc -, then write it back as (if possible valid) html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top