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

Don't inherit SVG style properties from the environment. #1089

Merged
merged 3 commits into from
Jan 25, 2018

Conversation

davidflanagan
Copy link

We don't want to inherit styles that affect SVG painting unless those
styles also affect regular text rendering. This patch adds styles
to the stylesheet so that every svg element in KaTeX output starts
off with a known set of basic fill and stroke attributes.

This should resolve issue #1088

We don't want to inherit styles that affect SVG painting unless those
styles also affect regular text rendering. This patch adds styles
to the stylesheet so that every svg element in KaTeX output starts
off with a known set of basic fill and stroke attributes.

This should resolve issue #1088
@davidflanagan
Copy link
Author

This screenshot was created by using the npm start testbed, and adding some new style properties on the

element that contains the KaTeX output. It demonstrates that with this patch applied, we inherit color, font-size and transform, but we are not affected by things like fill-opacity and stroke-width.

screen shot 2018-01-24 at 4 37 17 pm

Compare this screenshot to the one in issue #1088

Note also that previously we inherited fill color for elements, but not the stroke color, so it was possible for the environment to add a colored outline to our svg paths. Now we inherit both fill and stroke on the svg element itself, so setting the stroke style does not give a colored outline.

@davidflanagan
Copy link
Author

Okay, still need to make tests pass, but I'm hoping that the fix can be basically as simple as this.

@kevinbarabash
Copy link
Member

@davidflanagan maybe add a screenshot test for this. It should be possible using the pre and post properties in ss_data.yaml to construct a container with styles that would affect the rendering without your changes. Something like:

SvgReset:
    pre: <div style="fill-opacity: 0.5; stroke-width: 3, ...">
    tex: \sqrt{x+1}
    post: </div>

@davidflanagan
Copy link
Author

That's a great idea, Kevin. I'll do it.

@davidflanagan
Copy link
Author

Actually, the pre and post attributes on the screenshot tests set the content of spans before and after the math, but they're both siblings of the math element, not ancestors, so I can't use them to set styles that would affect the math...

Copy link
Member

@kevinbarabash kevinbarabash 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