W3C home > Mailing lists > Public > html-tidy@w3.org > July to September 2005

Re: Strip NOLAYER and everything inside? (urgent)

From: Yury V. Zaytsev <zaytsev@sandy.ru>
Date: Sun, 21 Aug 2005 17:23:24 +0400
Message-ID: <1815760000.20050821172324@sandy.ru>
To: html-tidy@w3.org

Hello, list!

Actually, I've got the problem solved in some way. I haven't found the
solution  on  how  to  delete  everything  inside  NOLAYER, but I have
figured   out   that   one   can   add  a  check  if  the  element  is
DescendantOf(element,  TIDY_NOLAYER)  in  the  MoveToHead  function of
parser.c  and  then  use  DiscardElement(element) to discard the whole
stylesheet  definition  after  it  gets moved to HEAD from the NOLAYER
tag.  Then  TIDY  will  delete unneeded empty NOLAYER tags... that was
meant  to  defeat NetObjects Fusion code generator. Looks like a dirty
hack, but that works.

But  finally  it  turned out that the task was to make TIDY just strip
off the NOLAYER tags, and not everything inside as well. I figured out
that we need to modify the ParseBlock function of parser.c like this:

---------------------------------------------------------------------

void ParseBlock( TidyDocImpl* doc, Node *element, uint mode)
{
    Lexer* lexer = doc->lexer;
    Node *node;
    Bool checkstack = yes;
    uint istackbase = 0;

    // ZYV remove nolayer
    if (TagIsId(element, TidyTag_NOLAYER )) {

        ReportError(doc, element, element, DISCARDING_UNEXPECTED);
        DiscardElement(doc, element);

        return;
    }

---------------------------------------------------------------------

That seems to work and pass all the regression tests. Please note that
it might not be the best solution, since I am absolutely new to TIDY's
source code and have a very rough idea on how the parser works.

Anyway, I thought that my findings might be useful for someone...

Thanks,

-- 
Sincerely yours,
Yury V. Zaytsev
Received on Sunday, 21 August 2005 13:23:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:55 GMT