HTML tags optimization [ interesting problem]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DENG

    #1

    HTML tags optimization [ interesting problem]


    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>TEXT 2</u></i></b>

    optimise to

    <i><b>TEXT1<u>T EXT2</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>TEX T</i></i>
    =>
    <i>TEXT</i>

    etc...

  • Bruno Desthuilliers

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

    DENG a écrit :[color=blue]
    > 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>TEXT 2</u></i></b>
    >
    > optimise to
    >
    > <i><b>TEXT1<u>T EXT2</u></b><i>[/color]

    Doesn't Tidy do this already ?
    [color=blue]
    >
    > 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>[/color]

    Whoever writes such a thing in 2005 ought to be shot down for the sake
    of mankind !-)
    [color=blue]
    > optimise to
    >
    > <font color=red size=6>TEXT1</font>[/color]

    You call this "optimized HTML" ? Even MS Word produces better code...
    [color=blue]
    >
    > 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,[/color]

    Tidy is open source AFAICT.
    [color=blue]
    > I
    > had too much thinking and get fool now
    >
    >
    > anyone can give me some advices?[/color]

    Learn to use Tidy and CSS.

    Comment

    • DENG

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

      Comment

      • DENG

        #4
        Re: HTML tags optimization [ interesting problem]

        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

        Comment

        • bruno modulix

          #5
          Re: HTML tags optimization [better learn CSS]

          DENG wrote:[color=blue]
          > I know very well Tidy, sir
          >
          > Tidy do a nice job but it is writen in Java,[/color]

          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.
          [color=blue]
          > and have Python ported
          >
          > my aim is to learn Python, learn how to program[/color]

          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.
          [color=blue]
          > you are french, right? peut etre we can talk about it in ecole
          > polytechnique?[/color]

          Peut-être pas, je ne mets jamais les pieds chez les polytechniciens .
          [color=blue]
          > i'll be there waiting for you[/color]

          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 'onurb@xiludom. gro'.split('@')])"

          Comment

          • Sybren Stuvel

            #6
            Re: HTML tags optimization [ interesting problem]

            DENG enlightened us with:[color=blue]
            > i use SGMLParser to process HTML files, in order to do some
            > optimizations,
            >
            > something like this:
            >
            ><i><b>TEXT1</b></i><b><i><u>TEXT 2</u></i></b>
            >
            > optimise to
            >
            ><i><b>TEXT1<u> TEXT2</u></b><i>[/color]

            Why not optimize it to:

            <span class='onerole' >TEXT1</span>
            <span class='secondro le'>TEXT2</span>?
            [color=blue]
            > [ snipped stuff about <font> tags ][/color]

            If you're serious about using HTML, I suggest you read a book that's
            not ten years old.
            [color=blue]
            > anyone can give me some advices?[/color]

            Yes, read the following:

            http://www.w3.org/QA/Tips/


            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

            Comment

            • DENG

              #7
              Re: HTML tags optimization [ interesting problem]

              hi, Sybren,

              thanks for your reply, if use CSS:

              <span class=type1>tex t<span class=type2>tex t</span></span><span
              class=type1>tex t</span>

              optimise to:

              <span class=type1>tex t<span class=type2>tex t</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

              Comment

              Working...