diff --git a/src/delimiter.js b/src/delimiter.js index 698aafbc..cc3a4d93 100644 --- a/src/delimiter.js +++ b/src/delimiter.js @@ -782,6 +782,7 @@ const makeLeftRightDelim = function( export default { sqrtImage: makeSqrtImage, sizedDelim: makeSizedDelim, + sizeToMaxHeight: sizeToMaxHeight, customSizedDelim: makeCustomSizedDelim, leftRightDelim: makeLeftRightDelim, }; diff --git a/src/functions/delimsizing.js b/src/functions/delimsizing.js index f1fdd0af..1c887b11 100644 --- a/src/functions/delimsizing.js +++ b/src/functions/delimsizing.js @@ -124,6 +124,10 @@ defineFunction({ node.setAttribute("fence", "false"); } + node.setAttribute("stretchy", "true"); + node.setAttribute("minsize", delimiter.sizeToMaxHeight[group.size] + "em"); + node.setAttribute("maxsize", delimiter.sizeToMaxHeight[group.size] + "em"); + return node; }, }); diff --git a/test/__snapshots__/mathml-spec.js.snap b/test/__snapshots__/mathml-spec.js.snap index 367e4373..96180d29 100644 --- a/test/__snapshots__/mathml-spec.js.snap +++ b/test/__snapshots__/mathml-spec.js.snap @@ -556,6 +556,95 @@ exports[`A MathML builder should set href attribute for href appropriately 1`] = `; +exports[`A MathML builder should size delimiters correctly 1`] = ` + + + + + ( + + + M + + + ) + + + ( + + + M + + + ) + + + ( + + + M + + + ) + + + ( + + + M + + + ) + + + ( + + + M + + + ) + + + + (M) \\big(M\\big) \\Big(M\\Big) \\bigg(M\\bigg) \\Bigg(M\\Bigg) + + + +`; + exports[`A MathML builder should use for colorbox 1`] = ` diff --git a/test/mathml-spec.js b/test/mathml-spec.js index 611d5fc5..3b070e6f 100644 --- a/test/mathml-spec.js +++ b/test/mathml-spec.js @@ -65,6 +65,11 @@ describe("A MathML builder", function() { expect(getMathML("\\raisebox{0.25em}{b}")).toMatchSnapshot(); }); + it('should size delimiters correctly', () => { + expect(getMathML("(M) \\big(M\\big) \\Big(M\\Big) \\bigg(M\\bigg)" + + " \\Bigg(M\\Bigg)")).toMatchSnapshot(); + }); + it('should use for colorbox', () => { expect(getMathML("\\colorbox{red}{b}")).toMatchSnapshot(); });