DOM parser that allows HTML5-style </ in [removed] tag

后端 未结 6 1200
無奈伤痛
無奈伤痛 2020-11-28 06:14

Update: html5lib (bottom of question) seems to get close, I just need to improve my understanding of how it\'s used.

I am attempting to

6条回答
  •  -上瘾入骨i
    2020-11-28 06:59

    I added comment tags () in my jQuery template blocks (CDATA blocks also failed) and DOMDocument did not touch the internal HTML.

    Then, before I used the jQuery templates, I wrote a script to remove the comments.

    $(function() {
        $('script[type="text/x-jquery-tmpl"]').text(function() {
            // The comment node in this context is actually a text node.
            return $.trim($(this).text()).replace(/^$/, '$1');
        });
    });
    

    Not ideal, but I wasn't sure of a better workaround.

提交回复
热议问题