"Giovanni Luiz Gaio" <giovanni.gaio@bcb.gov.br> wrote:
Tidy is really wonderfull, but this time it isn't doing right.
WRONG.
The example involves
<A ...><P>...</P></A>
But that is not legal HTML and never ever has been.
To a first approximation, HTML elements are either "block" elements
or "inline" elements. Blocks are things like paragraphs, lists, tables,
headings. Inline elements are things like images, text styles, and
cross references. One important reason for being aware of the
distinction is that INLINE ELEMENTS MAY ONLY CONTAIN OTHER INLINE
ELEMENTS, NEVER BLOCKS.
"A" elements are inline elements.
"P" elements are block elements.
"A" elements MAY NOT contain "P" elements.
Ever.
Never could.
In my view, the best thing for Tidy to do would be to convert
<A x><P>y</P></A> into <P><A x>y</A></P>,
but <A x></A><P>y</P> is pretty good.
***As you see, Tidy takes the paragraph out of the anchor.
Yes. It *MUST*, if the result is to have even the slightest hope
of being even approximately legal HTML.
It should be kept inside to preserve the link!***
That's why simply turning it inside out would be better.
But you can't expect Tidy to worry too much about "preserving"
what never was a legal link in the first place. Did Tidy tell
you about the problem it was fixing? You should expect _some_
manual cleanup after Tidy has finished, unless the source page
was almost reasonable to begin with.