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

Prevent CHTML adaptice CSS from adding character CSS multiple times #796

Merged
merged 1 commit into from
May 1, 2022

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Apr 19, 2022

The CHTML adaptive CSS currently adds CSS rules for characters multiple times if they are used in multiple typeset calls. I.e., typesetting $$x$$, then adding another $$x$$ to the page and typesetting again will cause two copies of the CSS for the italic "x" to be added to the CHTML stylesheet.

This is due to the fact that the usage tracking for the characters uses a Set() object with arrays that represent the variant and the character in that variant, but since two arrays are different even if they contain the same content, the fact that ["italic", 0x1D465] was already in the set was not being taken into account.

This PR fixes the problem by using a string rather than the array as the element in the set. The original array is JSON stringified so that two copies of the arrays will be considered the same (while not disrupting the use as Usage<number> and Usage<string> since numbers and strings stringify as themselves).

@dpvc dpvc added this to the 3.2.1 milestone Apr 19, 2022
@dpvc dpvc requested a review from zorkow April 19, 2022 15:02
Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

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

Successfully merging this pull request may close these issues.

2 participants