From 7b5083f9824c350209121628d11f3f4c9ab53c41 Mon Sep 17 00:00:00 2001 From: David Flanagan Date: Thu, 25 Jan 2018 06:01:37 -0800 Subject: [PATCH] Don't inherit SVG style properties from the environment. (#1089) * Don't inherit SVG style properties from the environment. 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 * Default to stroke:none for elements --- static/katex.less | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/static/katex.less b/static/katex.less index 8e7b5f05..a014a2ba 100644 --- a/static/katex.less +++ b/static/katex.less @@ -441,13 +441,30 @@ position: absolute; // absolute relative to parent width: 100%; + // We want to inherit colors from our environment + fill: currentColor; + stroke: currentColor; + + // But path elements should not have an outline by default + // that would make them bigger than we expect. path { - fill: currentColor; + stroke: none; } - line { - stroke: currentColor; - } + // And we don't want to inherit any other style properties + // that could affect SVG rendering without affecting font + // rendering. So we reset these properties to their default + // values for every element. + // See https://www.w3.org/TR/SVG/painting.html + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; } .vertical-separator svg {