feat: Support \vcenter and \hbox (#2452)

* Support \vcenter, \raise, \lower, and \hbox

* Update screenshots

* Edit docs for strict and hbox to

* Fix typo for \hbox to

* Update Safari screenshot

* Augment docs for \vcentcolon

* Edit vcenter MathML comment.

* Remove pointless class from vcenter MathML

* Withdraw \raise and \lower

* Updatae Chrome and Firefox screenshots

* Update Safari screenshot

* Delete allowedInArgument setting

Co-authored-by: ylemkimon <y@ylem.kim>

* Update Chrome and Firefox screenshots

* Update Chrome and Firefox screenshots take 2

* Update screenshot

Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
Ron Kok
2020-11-14 01:45:14 -08:00
committed by GitHub
parent ebd86b90c4
commit 60aecbdfe2
16 changed files with 169 additions and 10 deletions

44
src/functions/vcenter.js Normal file
View File

@@ -0,0 +1,44 @@
// @flow
import defineFunction from "../defineFunction";
import buildCommon from "../buildCommon";
import mathMLTree from "../mathMLTree";
import * as html from "../buildHTML";
import * as mml from "../buildMathML";
// \vcenter: Vertically center the argument group on the math axis.
defineFunction({
type: "vcenter",
names: ["\\vcenter"],
props: {
numArgs: 1,
argTypes: ["original"], // In LaTeX, \vcenter can act only on a box.
allowedInText: false,
},
handler({parser}, args) {
return {
type: "vcenter",
mode: parser.mode,
body: args[0],
};
},
htmlBuilder(group, options) {
const body = html.buildGroup(group.body, options);
const axisHeight = options.fontMetrics().axisHeight;
const dy = 0.5 * ((body.height - axisHeight) - (body.depth + axisHeight));
return buildCommon.makeVList({
positionType: "shift",
positionData: dy,
children: [{type: "elem", elem: body}],
}, options);
},
mathmlBuilder(group, options) {
// There is no way to do this in MathML.
// Write a class as a breadcrumb in case some post-processor wants
// to perform a vcenter adjustment.
return new mathMLTree.MathNode(
"mpadded", [mml.buildGroup(group.body, options)], ["vcenter"]);
},
});