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

Is replacing a rule in renderer.rules a public API? #395

Open
shepmaster opened this issue Sep 1, 2020 · 0 comments
Open

Is replacing a rule in renderer.rules a public API? #395

shepmaster opened this issue Sep 1, 2020 · 0 comments

Comments

@shepmaster
Copy link

I want to add some basic safety checks to what HTML tags and attributes are allowed. Some playing around has shown that I can do something like this:

const original = instance.renderer.rules.htmltag;
instance.renderer.rules.htmltag = function myHtmltag(tokens, idx /*, options, env */) {
  const content = tokens[idx].content;
  
  if (someMagicTest(content)) {
    return original(tokens, idx);
  } else {
    return escapeHtml(content);
  }
};

However, it's not abundantly clear to me if this is an approved method, and I don't want to build on a private API that is subject to change.

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