Re: Wrapping scripts in CDATA for XHTML

Tieu --

These are basically the same changes as the c code.  However, here it
is:

In class PPrint, method printTree, the changes look like this:

  else if (node.tag == TagTable.tagStyle || node.tag ==
TagTable.tagScript) {
    condFlushLine(fout, indent);

    indent = 0;
//  condFlushLine(fout, indent);    LINE REMOVED AS REDUNDANT
    printTag(lexer, fout, mode, indent, node);
    flushLine(fout, indent);

    // Start of added code

    if (this.configuration.xHTML) {
      int savewraplen = this.configuration.wraplen;
      /* disable wrapping */
      this.configuration.wraplen = 0xFFFFFF;  /* a very large number */
      addC('<', linelen++);
      addC('!', linelen++);
      addC('[', linelen++);
      addC('C', linelen++);
      addC('D', linelen++);
      addC('A', linelen++);
      addC('T', linelen++);
      addC('A', linelen++);
      addC('[', linelen++);
      condFlushLine(fout, indent);
      this.configuration.wraplen = savewraplen;
    }

    // End of added code

    for (content = node.content;
            content != null;
            content = content.next)
        printTree(fout, (short)(mode | PREFORMATTED | NOWRAP |CDATA),
indent, lexer, content);

    condFlushLine(fout, indent);

    // Start of added code

    if (this.configuration.xHTML) {
      int savewraplen = this.configuration.wraplen;
      /* disable wrapping */
      this.configuration.wraplen = 0xFFFFFF;  /* a very large number */
      addC(']', linelen++);
      addC(']', linelen++);
      addC('>', linelen++);
      condFlushLine(fout, indent);
      this.configuration.wraplen = savewraplen;
    }

    // End of added code

    printEndTag(fout, mode, indent, node);
    flushLine(fout, indent);

    if (this.configuration.IndentContent == false && node.next != null)
        flushLine(fout, indent);
  }

HTH,
Gary

"Tieu H.Luu" wrote:
> 
> Hi Gary,
> 
> I'm using JTidy to convert HTML to XHTML and also need to wrap scripts in
> CDATA.  I was wondering if you could post the changes that you made to the
> Java version of Tidy to accomplish this.
> 
> Thanks in advance,
> Tieu Luu

Received on Tuesday, 11 July 2000 17:41:57 UTC