-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add Safe extension and component #514
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly typos. O/w a couple of points for clarification.
ts/ui/safe/safe.ts
Outdated
const attributes = node.attributes.getAllAttributes(); | ||
for (const id of Object.keys(attributes)) { | ||
if (this.filterAttributes.hasOwnProperty(id)) { | ||
const value = this.filterMethods[this.filterAttributes[id]](this, attributes[id]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it certain that for every filterAttribute
there will be a filterMethod
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is certain. What are you suggesting? Checking and reporting an error if not? Isn't that what will happen anyway if not? Because this will be called on every attribute on every node, it should be kept as slim as possible. If someone adds a filterAttribute
without creating the corresponding filterMethod
, then they will get an error message at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we should catch that error at this point, i.e., if the filterMethod
does not exist, then we could simply continue in the loop, or throw an explicit error, rather than get a undefined is not a function
error.
I've made the fixes you requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
This PR ports the Safe extension from v2 to v3. It hooks into the MathML input jax via the
filterAttribute()
method that was set up for that, and via a newfilterClassList()
for handling the class attribute. Some adjustments were made to make handling the filters a bit easier.It hooks into the TeX input jax as a post filter. In v2, it hooked into the TeX parser itself so that it only filtered user-supplied values, but that is hard to maintain, as it must be aware of all the extensions and when user input is allowed. The post-filter avoids that, at the expense of having to look at all the attributes of all the elements, so it is less efficient, but more reliable.
This PR includes a component for the safe extension, so it can be loaded from the CDN. it also corrects an error in handling
fontsize
in thecommon/Wrapper.ts
file.