<title>Intents as CSS</title>
<link href="https://mathmlmuses.netlify.app/intents-as-css-styles/"/>
<updated>2022-09-20T00:07:51+00:00</updated>
<id>https://mathmlmuses.netlify.app/intents-as-css-styles/</id>
<content type="html"><h2 id="mathml-intents">MathML Intents<a class="tdbc-anchor" href="#mathml-intents">#</a></h2>
<p>MathML Intents is a proposed evolution to be elaborated within MathML4,
a specification that is to be produced by the newly formed
<a href="https://www.w3.org/Math/">Math Working Group of the W3C</a></p>
<p>Intents should help into making loud-readable mathematical formulæ written
in presentation MathML. A rich start of "default intents" has been
compiled in <a href="https://docs.google.com/spreadsheets/d/e/2PACX-1vTD9H2hQjgXXbkZrqkJQbTawwwrvlDfrTlVZRY8iF49jkJZ2rYfQX4QK39GlLhIuK0Fhhwkm_NnAcqm/pubhtml">this table</a>.
Intents could give a hint toward bringing some <em>semantic</em> into MathML-presentation expressions.</p>
<p>However, it is clear that such a list is never going to be one-size fits all.
Some of main symbols my favorite math topics are not there (e.g. the amalgamated product
of finitely generated groups or the homotopy groups) and different
ways of saying will always come e.g. the pipe when in P(A|B) or in {x| x>3}
(non-use of a math-specific syntax is intentional ;-)). One plans
an intent attribute value to be puttable on every MathML-presentation
element. That's good and useful for specific intents. But repeating
that the "|"-symbol should be said as a <em>conditional to</em> and not
a <em>such that</em> bloats the source.</p>
<hr>
<h2 id="what-if">What if...<a class="tdbc-anchor" href="#what-if">#</a></h2>
<p>... the <code>intent</code> attribute value could be specified by using styles
of the cascading stylesheet. Let us suppose, for example, that a
<code>mathintent-<intent-pattern></code> property value of CSS exists for each
thinkable intent-pattern (that's the <em>known notation</em> in
<a href="https://docs.google.com/spreadsheets/d/e/2PACX-1vTD9H2hQjgXXbkZrqkJQbTawwwrvlDfrTlVZRY8iF49jkJZ2rYfQX4QK39GlLhIuK0Fhhwkm_NnAcqm/pubhtml">the intent values table</a>).</p>
<p>This means that this property can be put inside a rule within the web-page body
or within a stylesheet and indicate:</p>
<ul>
<li>an intent value for every occurrence of a particular MathML-element's pattern (as is done in the list)</li>
<li>an intent value for such but within a particular class (e.g. an indication that a given expression is in probability-theory,
e.g. <nobr>P(A|B)</nobr> or that other is a set description as in <nobr>{x | x² > 1}</nobr>.</li>
</ul>
<p>And it also probably means that the best practice where CSS has been applied to accessibility
such as the reading-mode of browsers, the high-contrast skin-change, or user-adjustments can
all be made too.</p>
<hr>
<h2 id="examples">Examples<a class="tdbc-anchor" href="#examples">#</a></h2>
<h3 id="translating">Translating<a class="tdbc-anchor" href="#translating">#</a></h3>
<p>An author wishes to write down and make effective in his web-publications in, say, German.
For this, he wishes to apply translations of the intents for his notations. His usage of mathematical symbols
is rather moderate and he holds a table of symbols at the introduction of his web-publications anyways.</p>
<p>Thus our author realizes a stylesheet for its his web-publication so that
it is enough to write presentation MathML and have them speak-aloud-pronounceable in German.</p>
<p>A slight extract could be the following, where the suffix after <code>mathintent</code> should be read as
a pattern of MathML element names and character names either as entity or unicode names.</p>
<pre class="language-css"><code class="language-css"> <span class="token selector">*[lang="de"]</span> <span class="token punctuation">{</span><br> <span class="token property">mathintent-mo-equal</span><span class="token punctuation">:</span> <span class="token string">"$1 gleich $2"</span><span class="token punctuation">;</span><br> <span class="token property">mathintent-mo-lt</span><span class="token punctuation">:</span> <span class="token string">"$1 kleiner als $2"</span><span class="token punctuation">;</span><br> <span class="token property">mathintent-mi-cm</span><span class="token punctuation">:</span> <span class="token string">"Zentimeter"</span><span class="token punctuation">;</span><br> <span class="token punctuation">}</span></code></pre>
<h3 id="mark-context-to-choose-intent">Mark context to choose intent<a class="tdbc-anchor" href="#mark-context-to-choose-intent">#</a></h3>
<p>While the list of intents provides an intent for many symbol patterns, there may be a lot of ambiguity left.
As an example <code><mo>|</mo></code> could be automatically endowed with:</p>
<ul>
<li>the intent <code>such-that</code> with a speech hint <code>$1 such that $2</code></li>
<li>the intent <code>conditional-probability</code> with a speech hint <code>$1 given $2</code></li>
</ul>
<p>Supposing that the following stylesheet can be written:</p>
<pre class="language-css"><code class="language-css"> <span class="token selector">.conditional-prob</span> <span class="token punctuation">{</span><br> <span class="token property">mathintent-mo-mid</span><span class="token punctuation">:</span> <span class="token string">"$1 given $2"</span><span class="token punctuation">;</span><br> <span class="token punctuation">}</span><br> <span class="token selector">.set</span> <span class="token punctuation">{</span><br> <span class="token property">mathintent-mo-mid</span><span class="token punctuation">:</span> <span class="token string">"$1 such that $2"</span><span class="token punctuation">;</span><br> <span class="token punctuation">}</span></code></pre>
<p>Note that <code>mid</code> is the name of the entity
of the pipe character, it could have been <code>DIVIDES</code> (the unicode name), <code>VerticalBar</code> or...
The above stylesheet could then be used in the following expressions:</p>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>math</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mrow</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>conditional-prob<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>P<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>(<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mi</span><span class="token punctuation">></span></span>A<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mi</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>|<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mi</span><span class="token punctuation">></span></span>B<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mi</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>)<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mrow</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>=<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mrow</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>set<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>P<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>(<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mfenced</span> <span class="token attr-name">open</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>{<span class="token punctuation">"</span></span> <span class="token attr-name">close</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>}<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mrow</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mi</span><span class="token punctuation">></span></span>x<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mi</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span>|<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>msup</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mi</span><span class="token punctuation">></span></span>x<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mi</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mn</span><span class="token punctuation">></span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mn</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>msup</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mo</span><span class="token punctuation">></span></span><span class="token entity named-entity" title=">">&gt;</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mo</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mn</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mn</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mrow</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mfenced</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mrow</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>math</span><span class="token punctuation">></span></span></code></pre>
<h3 id="scoping-by-classname">Scoping by classname<a class="tdbc-anchor" href="#scoping-by-classname">#</a></h3>
<p>A magazine or conference web-site presents the abstracts of the various contributions.
Some abstracts are from different communities so that, say, the expression <em>A~B</em> should either
be pronounced as <em>A is congruent to B</em> or as <em>A follows the distribution B</em>.</p>
<p>Because each abstract can be tagged with a classname denoting the "area" it belongs
to. The different intents are inherited without the editor actually modifying the
MathML expressions of each of the abstracts.</p>
<hr>
<h2 id="challenges-&-hopes">Challenges & Hopes<a class="tdbc-anchor" href="#challenges-&-hopes">#</a></h2>
<p>Supposing that this becomes widespread practice (indeed, accesibility is becoming
more and more of a legal requirement and intents bring an operational way to do so),
collecting the stylesheets found around the web could offer a way to complement and,
more a challenge, <strong>collect translations</strong> in multiple languages and communities for the
intents' table (the one above really is for the English-speakers only).</p>
<p>Accessibility devices that work with browsers don't get the CSS... That is a problem
if operating on mandate of a browser that has loaded a static HTML page. However, CSS
inheritance works rather well in most browsers and could, thus, be ported to attributes
of the DOM by a JavaScript running in the browser before the accessibility device is addressed.
More concretely, the javascript piece would request all inherited properties on any given node
and then apply, say, <code>mathintent-mo-mid: "$1 given $2"</code> on all children of <code><mrow class="set"></code>
which can become an explicit style attribute which the accessibility tool can then use.
The idea is that such a style attribute is interpreted before the general table of default
intents and it can <em>fire</em> with more priority than it. This offers a way for authors to create
context... and hopefully for authors of the table of default intents to take advantage of it
to find more intents in different contexts (math domains, languages...).</p>
<p>Changing stylesheet to adjust the purpose might be useful here too: Creating different stylesheets
for different recipients and customising stylesheet because of one's stronger knowledge might
help the users of accessibility devices obtain a more relevant experience. The change could
be in the browser level, at the level of a classroom, at the level of an author, or
even at the software level.</p>
<p>And if CSS is still not the right selection language for the stylesheets to be authored...
there's a lot of generator out there: You can really industrialize the production of the CSS rules
that will produce intents to be applied to the very specific category or media.</p>
<hr>
<h2 id="now-what">Now what?<a class="tdbc-anchor" href="#now-what">#</a></h2>
<p>This little "what-if musing" was written to enrich the discussion in the Math community and working group.
After a first <a href="https://lists.w3.org/Archives/Public/public-mathml4/2021May/0001.html">announce</a>,
David Farmer and Deyan Ginev commented which resulted to the introduction of a property prefix.</p>
</content>