HTML tags optimization [ interesting problem]

Discussion in 'Python' started by DENG, Aug 31, 2005.

  1. DENG

    DENG Guest

    hi all,

    i use SGMLParser to process HTML files, in order to do some
    optimizations,

    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...
     
    DENG, Aug 31, 2005
    #1
    1. Advertising

  2. Re: HTML tags optimization [better learn CSS]

    DENG a écrit :
    > hi all,
    >
    > i use SGMLParser to process HTML files, in order to do some
    > optimizations,
    >
    > 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>


    Doesn't Tidy do this already ?

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


    Whoever writes such a thing in 2005 ought to be shot down for the sake
    of mankind !-)

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


    You call this "optimized HTML" ? Even MS Word produces better code...

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


    Tidy is open source AFAICT.

    > I
    > had too much thinking and get fool now
    >
    >
    > anyone can give me some advices?


    Learn to use Tidy and CSS.
     
    Bruno Desthuilliers, Aug 31, 2005
    #2
    1. Advertising

  3. DENG

    DENG Guest

    Re: HTML tags optimization [better learn CSS]

    I know very well Tidy, sir

    Tidy do a nice job but it is writen in Java, and have Python ported

    my aim is to learn Python, learn how to program

    I know many people write "hello the world" in 2005, why I can not write
    this program in 2005?

    you are french, right? peut etre we can talk about it in ecole
    polytechnique? i'll be there waiting for you

    thanks
     
    DENG, Sep 1, 2005
    #3
  4. DENG

    DENG Guest

    I know very well Tidy, sir

    Tidy do a nice job but it is writen in Java, and have Python ported

    my aim is to learn Python, learn how to program

    I know many people write "hello the world" in 2005, why I can not write
    this program in 2005?

    you are french, right? peut etre we can talk about it in ecole
    polytechnique? i'll be there waiting for you

    thanks
     
    DENG, Sep 1, 2005
    #4
  5. Re: HTML tags optimization [better learn CSS]

    DENG wrote:
    > I know very well Tidy, sir
    >
    > Tidy do a nice job but it is writen in Java,


    Seems like we're not talking about the same program here. Tidy (aka
    HTMLTidy) is written in C. You must be talking about it's Java port JTidy.

    > and have Python ported
    >
    > my aim is to learn Python, learn how to program


    No one could have guess from your post, and I dont have psychic powers,
    ok ?

    From a professional POV, using existing tools that have proven to be
    reliable is far better than reinventing the square wheel, hence my answer.

    > you are french, right? peut etre we can talk about it in ecole
    > polytechnique?


    Peut-être pas, je ne mets jamais les pieds chez les polytechniciens.

    > i'll be there waiting for you


    I'm afraid you'll learn a looooong time.

    Regards,
    --
    bruno desthuilliers
    python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
    p in ''.split('@')])"
     
    bruno modulix, Sep 1, 2005
    #5
  6. DENG enlightened us with:
    > i use SGMLParser to process HTML files, in order to do some
    > optimizations,
    >
    > 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>


    Why not optimize it to:

    <span class='onerole'>TEXT1</span>
    <span class='secondrole'>TEXT2</span>?

    > [ snipped stuff about <font> tags ]


    If you're serious about using HTML, I suggest you read a book that's
    not ten years old.

    > anyone can give me some advices?


    Yes, read the following:

    http://www.w3.org/QA/Tips/
    http://www.w3.org/TR/CSS21/
    http://www.w3.org/TR/xhtml1/
    http://validator.w3.org/

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
    Frank Zappa
     
    Sybren Stuvel, Sep 2, 2005
    #6
  7. DENG

    DENG Guest

    hi, Sybren,

    thanks for your reply, if use CSS:

    <span class=type1>text<span class=type2>text</span></span><span
    class=type1>text</span>

    optimise to:

    <span class=type1>text<span class=type2>text</span>text</span>

    what i need is the METHOD to do optimization, in fact, i have ready
    write a program to analyse the syntax of CSS, to make it works with all
    situation
     
    DENG, Sep 2, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dean H. Saxe
    Replies:
    0
    Views:
    1,052
    Dean H. Saxe
    Jan 3, 2004
  2. Rob Nicholson
    Replies:
    3
    Views:
    778
    Rob Nicholson
    May 28, 2005
  3. DENG

    HTML tags optimization

    DENG, Sep 2, 2005, in forum: Python
    Replies:
    2
    Views:
    288
    bruno modulix
    Sep 2, 2005
  4. Ravikiran

    Zero Optimization and Sign Optimization???

    Ravikiran, Nov 17, 2008, in forum: C Programming
    Replies:
    22
    Views:
    891
    Thad Smith
    Nov 24, 2008
  5. Roy Smith

    Interesting list() un-optimization

    Roy Smith, Mar 7, 2013, in forum: Python
    Replies:
    18
    Views:
    269
    Roy Smith
    Mar 10, 2013
Loading...

Share This Page