From 22dd4f3a28c99bf48a33a126c39f5486bcb01a5e Mon Sep 17 00:00:00 2001 From: Ron Kok Date: Wed, 22 Nov 2017 05:21:56 -0800 Subject: [PATCH] Append ApplyFunction to math functions (#960) * Append ApplyFunction to math functions As described at: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 Character U+2061 is the same as ⁡. Ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp * Add comment for \u2061 --- src/functions/op.js | 8 ++++++-- src/functions/operatorname.js | 4 +++- test/__snapshots__/mathml-spec.js.snap | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/functions/op.js b/src/functions/op.js index 4f8ff499..285c279d 100644 --- a/src/functions/op.js +++ b/src/functions/op.js @@ -209,8 +209,12 @@ const mathmlBuilder = (group, options) => { node = new mathMLTree.MathNode( "mi", [new mathMLTree.TextNode(group.value.body.slice(1))]); - // TODO(ron): Append an as in \operatorname - // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.2 + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + const operator = new mathMLTree.MathNode("mo", + [mml.makeText("\u2061", "text")]); + + return new domTree.documentFragment([node, operator]); } return node; diff --git a/src/functions/operatorname.js b/src/functions/operatorname.js index ef47d682..1a15b272 100644 --- a/src/functions/operatorname.js +++ b/src/functions/operatorname.js @@ -68,8 +68,10 @@ defineFunction({ const identifier = new mathMLTree.MathNode("mi", output); identifier.setAttribute("mathvariant", "normal"); + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp const operator = new mathMLTree.MathNode("mo", - [mml.makeText("⁡", "text")]); + [mml.makeText("\u2061", "text")]); return new domTree.documentFragment([identifier, operator]); }, diff --git a/test/__snapshots__/mathml-spec.js.snap b/test/__snapshots__/mathml-spec.js.snap index ad4b36d7..3b378772 100644 --- a/test/__snapshots__/mathml-spec.js.snap +++ b/test/__snapshots__/mathml-spec.js.snap @@ -27,6 +27,9 @@ exports[`A MathML builder should generate the right types of nodes 1`] = ` sin + + ⁡ + x