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

How can I prevent escaping html entities? #143

Closed
differui opened this issue Jul 22, 2016 · 3 comments
Closed

How can I prevent escaping html entities? #143

differui opened this issue Jul 22, 2016 · 3 comments
Labels

Comments

@differui
Copy link

differui commented Jul 22, 2016

Here is my html:

<span>></span>

After parse and serialize by parse5:

<span>&gt;</span>

Here is escapeString method:

Serializer.escapeString = function (str, attrMode) {
    str = str
        .replace(AMP_REGEX, '&amp;')
        .replace(NBSP_REGEX, '&nbsp;');

    if (attrMode)
        str = str.replace(DOUBLE_QUOTE_REGEX, '&quot;');

    else {
        str = str
            .replace(LT_REGEX, '&lt;')
            .replace(GT_REGEX, '&gt;');
    }

    return str;
};

How can I disable this function?

@inikulin
Copy link
Owner

How can I disable this function?

Why would you like to disable it? What's your scenario?

@differui
Copy link
Author

differui commented Jul 22, 2016

@inikulin I am using parse5 process .cshtml docs aka Razor which is template language of .NET MVC framework.

In Razor => is something else meaning.After process of parse5 the => will be replaced into =&gt; which lead to syntax error.

So I am asking for preventing from parse5 replacing html entities.

@inikulin
Copy link
Owner

If razor is not a subset of HTML syntax, you shouldn't use HTML parser for it. Use razor parser instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants