[kupu-dev] Kupu XHTML and libxml2
Duncan Booth
duncan.booth at suttoncourtenay.org.uk
Thu Jan 15 15:56:46 CET 2009
"Laurence Rowe" <l at lrowe.co.uk> wrote:
> 2009/1/1 Morten W. Petersen <morten at nidelven-it.no>:
>> it barfs on the kupu configuration section:
>>
>> # <div style="display: none;">
>> # <xml id="kupuconfig" class="kupuconfig">
>> # <kupuconfig>
>> #
>> # <dst>fulldoc.html</dst>
>> # <use_css>0</use_css>
>> # <reload_after_save>0</reload_after_save>
>> # ...
>>
>> Any ideas on how that can be fixed?
>
> I've just run into the same problem with the push parser interface of
> libxml2's HTMLParser (it seems the htmlCtxtRead* functions are more
> forgiving). As this is running in a proxy (to apply the new plone.org
> theme), I'm reluctant to read the whole file to memory before parsing.
>
> Can anyone think of a quick and dirty workaround? Maybe wrapping the
> output into a javascript document.write?
>
Quick and dirty:
Edit kupu_plone_layer/kupu_wysiwyg_support.html
Find the <div style="display: none;"> which encloses the xml section.
Extract the xml content of the div, and write a Python script which
generates the example same XML.
Modify the script so that it removes newlines, escapes quotes, and wraps
the whole thing in a document.write.
Edit the div tag so it reads: <div tal:replace="structure
python:context.kupu_create_xmlconfig(field)">
(I'm not sure exactly what parameters you'll need to pass the script)
For bonus points move it from being a script to being a method on the
kupu tool.
Optionally: update the .kupu files to generate the correct tal in the
div tag otherwise you'll have to reapply the hack every time kupu is
updated.
More information about the kupu-dev
mailing list