namespace "http://www.w3.org/1999/xhtml";
namespace html = "http://www.w3.org/1999/xhtml";
namespace g = "urn:x-mlmind:namespace:group";

(: Merge adjacent p-DefinitionExample paragraphs. :)

for-each /html/body//p[get-class("p-DefinitionExample")] {
    set-variable("container", (./preceding-sibling::*)[last()]);
    if $container and get-class("p-DefinitionExample", $container) {
       insert-into(<g:envelope>&#xA;</g:envelope>, false(), $container);
       insert-into(copy(./node()), false(), $container);
       delete();
    }
}

(: Wrap the content of a p-DefinitionExample paragraph into a pre.
   Yes, this make the paragraph temporarily invalid. :)
   
for-each /html/body//p[get-class("p-DefinitionExample")] {
    set-variable("content", copy(./node()));
    delete(./node());
    
    set-variable("wrapper", <pre></pre>);
    insert-into($wrapper);
    insert-into($content, false(), $wrapper);
}
