mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 04:08:43 +00:00
Move "raisebox" into functions/raisebox.js. (#1331)
This commit is contained in:
committed by
Kevin Barabash
parent
ea7003ff6e
commit
35d6181a95
@@ -247,7 +247,7 @@ type ParseNodeTypes = {
|
||||
|},
|
||||
"raisebox": {|
|
||||
type: "raisebox",
|
||||
dy: ParseNode<*>,
|
||||
dy: ParseNode<"size">,
|
||||
body: ParseNode<*>,
|
||||
value: ParseNode<*>[],
|
||||
|},
|
||||
|
@@ -12,7 +12,6 @@ import Style from "./Style";
|
||||
|
||||
import buildCommon from "./buildCommon";
|
||||
import domTree from "./domTree";
|
||||
import { calculateSize } from "./units";
|
||||
import utils from "./utils";
|
||||
import stretchy from "./stretchy";
|
||||
import {spacings, tightSpacings} from "./spacingData";
|
||||
@@ -570,25 +569,6 @@ export const groupTypes = {
|
||||
|
||||
return makeSpan(["mrel", "x-arrow"], [vlist], options);
|
||||
},
|
||||
|
||||
raisebox(group, options) {
|
||||
const body = groupTypes.sizing({value: {
|
||||
value: [{
|
||||
type: "text",
|
||||
value: {
|
||||
body: group.value.value,
|
||||
font: "mathrm", // simulate \textrm
|
||||
},
|
||||
}],
|
||||
size: 6, // simulate \normalsize
|
||||
}}, options);
|
||||
const dy = calculateSize(group.value.dy.value, options);
|
||||
return buildCommon.makeVList({
|
||||
positionType: "shift",
|
||||
positionData: -dy,
|
||||
children: [{type: "elem", elem: body}],
|
||||
}, options);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -304,14 +304,6 @@ groupTypes.xArrow = function(group, options) {
|
||||
return node;
|
||||
};
|
||||
|
||||
groupTypes.raisebox = function(group, options) {
|
||||
const node = new mathMLTree.MathNode(
|
||||
"mpadded", [buildGroup(group.value.body, options)]);
|
||||
const dy = group.value.dy.value.number + group.value.dy.value.unit;
|
||||
node.setAttribute("voffset", dy);
|
||||
return node;
|
||||
};
|
||||
|
||||
groupTypes.tag = function(group, options) {
|
||||
const table = new mathMLTree.MathNode("mtable", [
|
||||
new mathMLTree.MathNode("mlabeledtr", [
|
||||
|
@@ -2,7 +2,6 @@
|
||||
/** Include this to ensure that all functions are defined. */
|
||||
import {
|
||||
default as _defineFunction,
|
||||
ordargument,
|
||||
_functions,
|
||||
} from "./defineFunction";
|
||||
|
||||
@@ -124,20 +123,7 @@ import "./functions/cr";
|
||||
import "./functions/environment";
|
||||
|
||||
// Box manipulation
|
||||
defineFunction("raisebox", ["\\raisebox"], {
|
||||
numArgs: 2,
|
||||
argTypes: ["size", "text"],
|
||||
allowedInText: true,
|
||||
}, function(context, args) {
|
||||
const amount = args[0];
|
||||
const body = args[1];
|
||||
return {
|
||||
type: "raisebox",
|
||||
dy: amount,
|
||||
body: body,
|
||||
value: ordargument(body),
|
||||
};
|
||||
});
|
||||
import "./functions/raisebox";
|
||||
|
||||
import "./functions/verb";
|
||||
|
||||
|
56
src/functions/raisebox.js
Normal file
56
src/functions/raisebox.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// @flow
|
||||
import defineFunction, {ordargument} from "../defineFunction";
|
||||
import buildCommon from "../buildCommon";
|
||||
import mathMLTree from "../mathMLTree";
|
||||
import {assertNodeType} from "../ParseNode";
|
||||
import {calculateSize} from "../units";
|
||||
|
||||
import * as html from "../buildHTML";
|
||||
import * as mml from "../buildMathML";
|
||||
|
||||
// Box manipulation
|
||||
defineFunction({
|
||||
type: "raisebox",
|
||||
names: ["\\raisebox"],
|
||||
props: {
|
||||
numArgs: 2,
|
||||
argTypes: ["size", "text"],
|
||||
allowedInText: true,
|
||||
},
|
||||
handler(context, args) {
|
||||
const amount = assertNodeType(args[0], "size");
|
||||
const body = args[1];
|
||||
return {
|
||||
type: "raisebox",
|
||||
dy: amount,
|
||||
body: body,
|
||||
value: ordargument(body),
|
||||
};
|
||||
},
|
||||
htmlBuilder(group, options) {
|
||||
const body = html.groupTypes.sizing({value: {
|
||||
value: [{
|
||||
type: "text",
|
||||
value: {
|
||||
body: group.value.value,
|
||||
font: "mathrm", // simulate \textrm
|
||||
},
|
||||
}],
|
||||
size: 6, // simulate \normalsize
|
||||
}}, options);
|
||||
const dy = calculateSize(group.value.dy.value, options);
|
||||
return buildCommon.makeVList({
|
||||
positionType: "shift",
|
||||
positionData: -dy,
|
||||
children: [{type: "elem", elem: body}],
|
||||
}, options);
|
||||
},
|
||||
mathmlBuilder(group, options) {
|
||||
const node = new mathMLTree.MathNode(
|
||||
"mpadded", [mml.buildGroup(group.value.body, options)]);
|
||||
const dy = group.value.dy.value.number + group.value.dy.value.unit;
|
||||
node.setAttribute("voffset", dy);
|
||||
return node;
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user