logo       

Re: Is it possibile to control the well-formed XML produced by kupu?: msg#00015

web.kupu.devel

Subject: Re: Is it possibile to control the well-formed XML produced by kupu?

Alessandra Donnini wrote:

> I would like to produce with kupu a part of a document not an entire
> document. In other words I would like that the document provided by kupu
> doesn't contain the head and the body html tags. Is it possible?
> Thanks,
> Alessandra Donnini
>

Yes, you just have to strip out the content from inside the body tag. Have
a look near the end of kupuploneeditor.js to see one way to do this.
Basically:

// Get the edited text and apply the cleanup filters
var transform =
this._filterContent(this.getInnerDocument().documentElement);

// Get the body tag as XML
var contents = kupu.getXMLBody(transform);

// Mozilla et al. insert a nearly empty paragraph if you start off with
// nothing at all, so it is best to strip that off.
if (/^<body[^>]*>(<\/?(p|br)[^>]*>|\&nbsp;)*<\/body>$/.test(contents)) {
contents = ''; /* Ignore nearly empty contents */
}
// Remove the body tag(s)
contents = contents.replace(/<\/?body[^>]*>/g, "");

The plone code is actually slightly longer since it also does things like
making all the links relative, but I've just pulled out the important
parts.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise