The message is submited via form. It can contain html as well as normal text.
i.e.:
Why this code doesn't work for me?
<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']);
    _gaq.push(['_trackPageview']);
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>
I would like to surround html element with pre tag.
i.e.
Why this code doesn't work for me?
<pre>
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXXXX-X']);
        _gaq.push(['_trackPageview']);
        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
</pre>
I asked earlier about it in php chat room and author of the answer in this question suggested to read the solution: php DOMDocument: complete transform of form element? wrapping and removing?
Everything is perfect in this example exept few things. I need to wrap any html element obviously exept pre itself.  
- If elements are folded, then wrap only outer element.
- If they are separate, then wrap each of them.
- If there is only open tag, then wrap it only(no need of fixing with close tag).
Does anyone have any possible idea for a solution to this question? Thanks in advance to all who can help.
 
     
    