Re: Strip NOLAYER and everything inside? (urgent)

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 UTC