Created
June 10, 2016 22:54
-
-
Save laughinghan/811933e6920980df5dc06fb35b3d6b2b to your computer and use it in GitHub Desktop.
`display: block` technique for rendering diacritics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/commands/math/commands.js b/src/commands/math/commands.js | |
index f763480..a9479f7 100644 | |
--- a/src/commands/math/commands.js | |
+++ b/src/commands/math/commands.js | |
@@ -495,7 +495,7 @@ var DiacriticAbove = P(MathCommand, function(_, super_) { | |
var htmlTemplate = | |
'<span class="mq-diacritic mq-non-leaf">' | |
+ '<span class="mq-diacritic-above">'+symbol+' </span>' | |
- + '<span class="mq-non-leaf mq-inset">&0</span>' | |
+ + '<span class="mq-diacritic-stem mq-inset">&0</span>' | |
+ '</span>' | |
; | |
@@ -507,8 +507,8 @@ var DiacriticAbove = P(MathCommand, function(_, super_) { | |
if (!(cmd.ctrlSeq in LOW_LETTERS)) allLow = false; | |
if (cmd.ctrlSeq === 't') anyTs = true; | |
}); | |
- this.jQ.toggleClass('mq-diacritic-low', allLow) | |
- .toggleClass('mq-diacritic-t', anyTs); | |
+ block.jQ.prev().toggleClass('mq-diacritic-low', allLow) | |
+ .toggleClass('mq-diacritic-t', anyTs); | |
}; | |
var LOW_ROMAN_LETTERS = 'acegmnopqrstuvwxyz'; | |
var LOW_GREEK_LETTERS = 'alpha gamma eta iota kappa mu nu rho sigma tau chi omega varphi epsilon varepsilon pi varpi varsigma upsilon digamma varkappa varrho psi'.split(' '); | |
diff --git a/src/css/math.less b/src/css/math.less | |
index 9d4658b..597aeab 100644 | |
--- a/src/css/math.less | |
+++ b/src/css/math.less | |
@@ -295,29 +295,25 @@ | |
padding-top: 1px; | |
} | |
- .mq-diacritic { | |
- position: relative; | |
- | |
- padding-top: .2em; | |
+ .mq-diacritic-above { | |
+ display: block; | |
+ text-align: center; | |
+ height: 0; | |
+ // use transparent border not margin or padding as Chrome workaround: | |
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=617763#c3 | |
+ border-top: .15em solid transparent; | |
+ border-bottom: .15em solid transparent; | |
&.mq-diacritic-low { | |
- padding-top: 0; | |
+ border-bottom: 0; | |
+ margin-bottom: -.05em; | |
+ margin-left: -.2em; | |
&.mq-diacritic-t { | |
- padding: .1em; | |
+ margin-bottom: 0; | |
} | |
} | |
} | |
- .mq-diacritic-above { | |
- position: absolute; | |
- left: 0; | |
- right: 0; | |
- text-align: center; | |
- | |
- top: .06em; // yes, really, .05em isn't low enough in Chrome, | |
- // .07em is too low in Firefox & Safari | |
- } | |
- .mq-diacritic-low > .mq-diacritic-above { | |
- left: -.1em; | |
- right: .1em; | |
+ .mq-diacritic-stem { | |
+ display: block; | |
} | |
.mq-large-operator { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment