Added base class for diacritics above letters
- \vec now uses the DiacriticAbove base class.
- Added \tilde command that also uses the same base class.
diff --git a/src/commands/math/commands.js b/src/commands/math/commands.js
index be5a269..db23c76 100644
--- a/src/commands/math/commands.js
+++ b/src/commands/math/commands.js
@@ -457,17 +457,6 @@
};
});
-var Vec = LatexCmds.vec = P(MathCommand, function(_, super_) {
- _.ctrlSeq = '\\vec';
- _.htmlTemplate =
- '<span class="mq-non-leaf">'
- + '<span class="mq-vector-prefix">→</span>'
- + '<span class="mq-vector-stem">&0</span>'
- + '</span>'
- ;
- _.textTemplate = ['vec(', ')'];
-});
-
var NthRoot =
LatexCmds.nthroot = P(SquareRoot, function(_, super_) {
_.htmlTemplate =
@@ -483,6 +472,25 @@
};
});
+var DiacriticAbove = P(MathCommand, function(_, super_) {
+ _.init = function(ctrlSeq, symbol, textTemplate) {
+ var htmlTemplate =
+ '<span class="mq-non-leaf">'
+ + '<span class="mq-diacritic-above">'+symbol+'</span>'
+ + '<span class="mq-diacritic-stem">&0</span>'
+ + '</span>'
+ ;
+
+ super_.init.call(this, ctrlSeq, htmlTemplate, textTemplate);
+ };
+});
+
+var Vec =
+LatexCmds.vec = bind(DiacriticAbove, '\\vec', '→', ['vec(', ')']);
+
+var Tilde =
+LatexCmds.tilde = bind(DiacriticAbove, '\\tilde', '~', ['tilde(', ')']);
+
function DelimsMixin(_, super_) {
_.jQadd = function() {
super_.jQadd.apply(this, arguments);
diff --git a/src/css/math.less b/src/css/math.less
index 954d27c..a627fca 100644
--- a/src/css/math.less
+++ b/src/css/math.less
@@ -271,7 +271,7 @@
padding-top: 1px;
}
- .mq-vector-prefix {
+ .mq-diacritic-above {
display: block;
text-align: center;
line-height: .25em;
@@ -279,7 +279,7 @@
font-size: 0.75em;
}
- .mq-vector-stem {
+ .mq-diacritic-stem {
display: block;
}