0

I pasted some content from word to htmleditor()【http://mindmup.github.io/bootstrap-wysiwyg/】,but some word-defined tags still in html like "< v:shape>< /v:shape>" and "< v:shapetype>< /v:shapetype>" and "< v:imagedata>< /v:imagedata>" and so on...

I have removed most of useless tag with jquery except this kind of tags .

all the followings dont work, like $(xxxxxx).find('v')/.find('v:shape')/.find('shape');. but $(xxxxxx).find('a')/.find('span') works well.

i want to use Regular Expressions to replace all < v:xxx>< /v:xxx> tags to < vword>< /vword> then remove all vword tags, but i dont know Regular Expressions syntax and in these 2 days i have no time learn it and i wonder whether it's the right way.

so,who can kindly tell me how and what i should do? thx.

this works well:

container.find("font").each(function () {
$(this).replaceWith(function () { return $(this).contents(); });
});

this doesnt work:

container.find("v").each(function () {
$(this).remove();
});
container.find("shape").each(function () {
$(this).remove();
});
container.find("shapetype").each(function () {
$(this).remove();
});
container.find("v:shape").each(function () {
$(this).remove();
});
container.find("v:shapetype").each(function () {
$(this).remove();
});

2 Answers 2

0

Is there supposed to be a space after each "<"? Assuming that's a typo, this should work for you:

match: <v:(\w+)>(.*?)</v:\1>

replace: <v\1>\2</v\1>

0

I used other ways to fix the problem:

First,

    container.find('*').each(function () {
        if ($(this).get(0).tagName == 'V:SHAPE') {
            $(this).remove();
        }
    });

Second, i found another post about this kind of tag: http://forum.jquery.com/topic/jquery-colon-in-xml-tag-on-webkit-cannot-select but it doesnt work for me. i searched 'jquery select tagname with colon' by google, and got this: Parsing XML with namespaces using jQuery $().find then i changed my solution to :

container.find('v\\:shape').each(function () {
    $(this).remove();
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.