Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<p> #26

Open
Czj1997-02 opened this issue Oct 21, 2022 · 0 comments
Open

<p> #26

Czj1997-02 opened this issue Oct 21, 2022 · 0 comments

Comments

@Czj1997-02
Copy link

Thanks for the contribution of the author. I have a good idea to deal with the problem of

tags.
the problem may be caused by incomplete regular matching, I found that thetag has a similar problem,

so it can be solved in this way.replace the label with regular before comparison

toHtml(text) {
        var reg1 = /<p/g;
        var reg2 = /<\/p>/g;
        var reg3 = /<strong/g;
        var reg4 = /<\/strong>/g;
        text = text.replace(reg1, "<div class='type-p' ");
        text = text.replace(reg2, "</div><div class='end-p'></div>");
        text = text.replace(reg3, "<div class='type-strong' ");
        text = text.replace(reg4, "</div><div class='end-strong'></div>");
        return text;
      },
diffhtml = HtmlDiff.execute(this.toHtml(actionData),this.toHtml(newData))

replaced after comparison

toEditor(text) {
        // 在转换后把p标签和strong标签换回来
        var reg5 = /<div class='type-p' /g;
        var reg6 = /<\/div><div class=\'end-p\'><\/div>/g;
        var reg7 = /<div class='type-strong' /g;
        var reg8 = /<\/div><div class=\'end-strong\'><\/div>/g;
        text = text.replace(reg5, "<p");
        text = text.replace(reg6, "</p>");
        text = text.replace(reg7, "<strong");
        text = text.replace(reg8, "</strong>");
        return text;
      },
diffhtml = this.toEditor(diffhtml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant