mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-13 23:18:38 +00:00
\@binrel command and refactor (#1487)
* \@binrel command and refactor New `\@binrel{x}{y}` command renders `y` as if it's a bin/rel/ord like `x`. This is equivalent to AMSTeX's `\binrel@{x}\binrel@@{y}`. It will hopefully be useful for macros, such as `\pmb` (#1418). Also refactor the (already duplicated) code for implementing this functionality into buildCommon.binrelClass. * Add tests; fix flow error * Another test * Move binrelClass to functions/mclass.js * Remove expensive array destructuring polyfill
This commit is contained in:
committed by
Kevin Barabash
parent
8f5239c272
commit
578877764d
@@ -2999,6 +2999,23 @@ describe("\\tag support", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("\\@binrel automatic bin/rel/ord", () => {
|
||||
it("should generate proper class", () => {
|
||||
expect("L\\@binrel+xR").toParseLike("L\\mathbin xR");
|
||||
expect("L\\@binrel=xR").toParseLike("L\\mathrel xR");
|
||||
expect("L\\@binrel xxR").toParseLike("L\\mathord xR");
|
||||
expect("L\\@binrel{+}{x}R").toParseLike("L\\mathbin{{x}}R");
|
||||
expect("L\\@binrel{=}{x}R").toParseLike("L\\mathrel{{x}}R");
|
||||
expect("L\\@binrel{x}{x}R").toParseLike("L\\mathord{{x}}R");
|
||||
});
|
||||
|
||||
it("should base on just first character in group", () => {
|
||||
expect("L\\@binrel{+x}xR").toParseLike("L\\mathbin xR");
|
||||
expect("L\\@binrel{=x}xR").toParseLike("L\\mathrel xR");
|
||||
expect("L\\@binrel{xx}xR").toParseLike("L\\mathord xR");
|
||||
});
|
||||
});
|
||||
|
||||
describe("A parser taking String objects", function() {
|
||||
it("should not fail on an empty String object", function() {
|
||||
expect(new String("")).toParse();
|
||||
|
Reference in New Issue
Block a user