{"id":174,"date":"2020-12-26T13:25:47","date_gmt":"2020-12-26T21:25:47","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/math-in-office\/?p=174"},"modified":"2020-12-31T10:38:53","modified_gmt":"2020-12-31T18:38:53","slug":"mathml-and-omml-user-selection-attributes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/math-in-office\/mathml-and-omml-user-selection-attributes\/","title":{"rendered":"MathML and OMML User Selection Attributes"},"content":{"rendered":"<p>Some assistive technology (AT) programs use <a href=\"https:\/\/www.w3.org\/TR\/MathML3\/chapter3.html\">MathML<\/a> or <a href=\"https:\/\/docs.microsoft.com\/en-us\/archive\/blogs\/murrays\/mathml-and-ecma-math-omml\">OMML<\/a> as conduits for generating math speech and braille from math-enabled apps. In addition, they would like to use these formats for <em>editing<\/em> math text as well as speaking it and displaying it on refreshable braille displays. To this end, the formats need selection attributes that identify where the user selection is or should be within the MathML or OMML. These selection attributes are intended for accessibility purposes; MathML\/OMML in copy, paste, and files ordinarily wouldn\u2019t contain such attributes.<\/p>\n<h2>User Selection<\/h2>\n<p>A user selection can be degenerate, that is, an insertion point, or nondegenerate in which case it selects one or more ranges of characters. Multiple disjoint selections (multiple ranges) can be made by using the Ctrl key and clicking appropriately. For math editing, multiple selections aren\u2019t generally very useful, and this post doesn\u2019t treat them. A nondegenerate selection has an <em>active<\/em> end, the end that moves when you enter Shift + an arrow key, and an <em>anchor<\/em> end. The two ends coincide for an insertion point.<\/p>\n<h2>Selection attributes<\/h2>\n<p>To specify the locations of the selection ends in any MathML\/OMML content, we define the attribute names selActiveEnd, selAnchorEnd, and selIP (insertion point). The values for these attributes are given in the table<\/p>\n<table>\n<tbody>\n<tr>\n<td>&#8220;before&#8221;<\/td>\n<td>Before math zone<\/td>\n<\/tr>\n<tr>\n<td>&#8220;after&#8221;<\/td>\n<td>After math zone<\/td>\n<\/tr>\n<tr>\n<td>&#8220;<em>n<\/em>&#8220;<\/td>\n<td>At offset <em>n<\/em> into an element<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The most common attribute is selIP with the value &#8220;0&#8221;, i.e., an insertion point at the start of the element, such as the MathML &lt;mi selIP=&#8221;0&#8243;&gt;a&lt;\/mi&gt; or the OMML &lt;m:t selIP=\u201d0\u201d&gt;\ud835\udc4e&lt;\/m:t&gt;.<\/p>\n<p>With elements containing more than one character like the MathML &lt;mi&gt;sin&lt;\/mi&gt;, the insertion point might be in between the \u2018s\u2019 and the \u2018i\u2019, in which case one has &lt;mi selIP=&#8221;1&#8243;&gt;sin&lt;\/mi&gt; and the OMML &lt;m:t selIP=\u201c1\u201d&gt;sin&lt;\/m:t&gt;. If the user then enters Shift+\u2192 to select the \u2018i\u2019, the MathML is &lt;mi selAnchorEnd=&#8221;1&#8243; selActiveEnd=&#8221;2&#8243;&gt;sin&gt;&lt;\/mi&gt; and the OMML is &lt;m:t selAnchorEnd=&#8221;1&#8243; selActiveEnd=&#8221;2&#8243;&gt;sin&lt;\/m:t&gt;.<\/p>\n<p>Another case is for an IP at the end of an object argument. For example, in the MathML fraction &lt;mfrac&gt;&lt;mn&gt;1&lt;\/mn&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;\/mfrac&gt;, if the IP follows the \u20182\u2019 in the denominator, the selIP attribute appears in MathML as &lt;mn selIP=&#8221;1&#8243;&gt;2&lt;\/mn&gt;. This IP is at the end of the denominator, not at the end of the fraction, and entering a character puts the character in the denominator following the \u20182\u2019. The corresponding OMML is &lt;m:t selIP=&#8221;1&#8243;&gt;2&lt;\/m:t&gt;.<\/p>\n<p>The offset <em>n<\/em> is given in code units of the Unicode encoding in use. Microsoft Office apps use UTF-16 for which most math alphanumerics are surrogate pairs, that is, 2 code units. If a fraction denominator is \ud835\udc65, an IP following the \ud835\udc65 is specified for a UTF-16 implementation by the MathML as &lt;mi selIP=&#8221;2&#8243;&gt;x&lt;\/mi&gt; even though MathML uses the single-unit ASCII letter x to represent the surrogate-pair math-alphabetic \ud835\udc65 (U+1D465). This choice is synchronized with the selection in memory. In OMML, math alphanumerics aren\u2019t translated to ASCII, so this size difference doesn\u2019t occur.<\/p>\n<h2>Nested objects<\/h2>\n<p>An IP or selection end can follow the last element of a parent element such as being after the parenthesized expression in (\ud835\udc4e + \ud835\udc4f)\u00b2 but still in the base of the superscript object. For an IP, this is given in MathML by an empty &lt;mrow selIP=&#8221;0&#8243;\/&gt;:<\/p>\n<pre>&lt;msup&gt;\r\n   &lt;mrow&gt;\r\n      &lt;mrow&gt;&lt;mo&gt;(&lt;\/mo&gt;&lt;mi&gt;a&lt;\/mi&gt;&lt;mo&gt;+&lt;\/mo&gt;&lt;mi&gt;b&lt;\/mi&gt;&lt;mo&gt;)&lt;\/mo&gt;&lt;\/mrow&gt;\r\n      &lt;mrow selIP=\"0\"\/&gt;&lt;\/mrow&gt;\r\n   &lt;mn&gt;2&lt;\/mn&gt;&lt;\/msup&gt;<\/pre>\n<p>In OMML, it\u2019s given by an empty run &lt;m:r selIP=&#8221;0&#8243;\/&gt;. The empty &lt;mrow&gt; or empty &lt;m:r&gt; is also used for an IP at the end of the math zone, but still in the math zone.<\/p>\n<h2>Selection end at start of math object<\/h2>\n<p>If an IP is at the start of a math object, such as a fraction, but before the first argument, the selection attribute goes in the math-object element. For example, for the fraction \u201c1 over 2\u201d, an IP at the start of the fraction is indicated by &lt;mfrac selIP=&#8221;0&#8243;&gt; in MathML and by &lt;m:f selIP=&#8221;0&#8243;&gt; in OMML.<\/p>\n<h2>Selection extending outside of math zone<\/h2>\n<p>A selection may start before a math zone and select part or all of the math zone. Similarly, it can start inside the math zone and extend beyond it. The attribute values &#8220;before&#8221; and &#8220;after&#8221; are used for such cases, respectively. For example, the math in the statement (selection is <span style=\"background-color: #00ffff;\">highlighted<\/span>) \u201cthe Pythagorean Theorem <span style=\"background-color: #00ffff;\">is \ud835\udc4e\u00b2<\/span> + \ud835\udc4f\u00b2 = \ud835\udc50\u00b2\u201d is represented by the MathML<\/p>\n<pre>&lt;math selAnchorEnd=\"before\"&gt;\r\n   &lt;msup&gt;&lt;mi&gt;a&lt;\/mi&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;\/msup&gt;\r\n   &lt;mo selActiveEnd=\"0\"&gt;+&lt;\/mo&gt;\r\n   &lt;msup&gt;&lt;mi&gt;b&lt;\/mi&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;\/msup&gt;\r\n   &lt;mo&gt;=&lt;\/mo&gt;\r\n   &lt;msup&gt;&lt;mi&gt;c&lt;\/mi&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;\/msup&gt;\r\n&lt;\/math&gt;<\/pre>\n<p>where the active end follows the \ud835\udc4e\u00b2. If the whole math zone is embedded in a selection with the active end at the selection end, &lt;math selAnchorEnd=&#8221;before&#8221; selActiveEnd=&#8221;after&#8221;&gt; is used. A selected empty math-zone place holder can be represented in MathML by &lt;math selIP=&#8221;0&#8243;\/&gt;.<\/p>\n<h2>Elements that take selection attributes<\/h2>\n<p>Although it would be possible to allow selection attributes on most any element, it\u2019s simpler to process and nevertheless general enough to restrict the elements that take selection attributes to<\/p>\n<ul>\n<li>Character elements: MathML &lt;mi&gt;, &lt;mn&gt;, &lt;mo&gt;, &lt;mtext&gt; and OMML &lt;m:t&gt;<\/li>\n<li>MathML &lt;mrow&gt; and OMML &lt;m:r&gt;<\/li>\n<li>Math object elements like MathML &lt;mfrac&gt; and OMML &lt;m:f&gt;<\/li>\n<li>Math zone element: MathML &lt;math&gt; and OMML &lt;oMath&gt;<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Some assistive technology (AT) programs use MathML or OMML as conduits for generating math speech and braille from math-enabled apps. In addition, they would like to use these formats for editing math text as well as speaking it and displaying it on refreshable braille displays. To this end, the formats need selection attributes that identify [&hellip;]<\/p>\n","protected":false},"author":40611,"featured_media":55,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-174","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-math-in-office"],"acf":[],"blog_post_summary":"<p>Some assistive technology (AT) programs use MathML or OMML as conduits for generating math speech and braille from math-enabled apps. In addition, they would like to use these formats for editing math text as well as speaking it and displaying it on refreshable braille displays. To this end, the formats need selection attributes that identify [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts\/174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/users\/40611"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}