w3c / w3c/mathml

Natural Language and Mathematics

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accessibility MathML-Next
Dominant language
HTML
Stars
82
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Introduction

We can consider scenarios where it is desired to utilize presentation content comprised of or containing natural language while also utilizing MathML4 features.

Examples are indicated, herein, towards a discussion of making it possible to style <math> elements such that presentation content can be displayed in an inline manner, flowing with surrounding hypertext and wrapping lines.

HTML5

In the following examples, it is shown that HTML5 can be used to present natural language for a mathematical expression for which a semantic component is also provided.

Can the <math> element be styled so that both of the following examples render in the same way?

Can the <math> element be styled to display in an inline manner, flowing with surrounding hypertext and wrapping lines?

Example 1
<p>
  <span>This is a previous sentence.</span>
  <span>Two plus two is four.</span>
  <span>This is a next sentence.</span>
</p>
Example 2
<p>
  <span>This is a previous sentence.</span>
  <math style="display:inline;text-wrap:wrap">
    <semantics>
      <annotation-xml encoding="application/xhtml+xml">
        <span>Two plus two is four.</span>
      </annotation-xml>
      <annotation-xml name="contentequiv" encoding="application/mathml-content+xml">
        <apply><eq />
          <apply><plus /><cn>2</cn><cn>2</cn></apply>
          <cn>4</cn>
        </apply>
      </annotation-xml>
    </semantics>
  </math>
  <span>This is a next sentence.</span>
</p>

MathML’s mtext

The following example shows that the mtext element can also be utilized to present natural language content in MathML.

<p>
  <span>This is a previous sentence.</span>
  <math style="display:inline;text-wrap:wrap">
    <semantics>
      <annotation-xml encoding="application/mathml-presentation+xml">
        <mtext>Two plus two is four.</mtext>
      </annotation-xml>
      <annotation-xml name="contentequiv" encoding="application/mathml-content+xml">
        <apply><eq />
          <apply><plus /><cn>2</cn><cn>2</cn></apply>
          <cn>4</cn>
        </apply>
      </annotation-xml>
    </semantics>
  </math>
  <span>This is a next sentence.</span>
</p>

Expression Metadata

We can make use of metadata to indicate mappings between some natural language content and mathematical semantics.

<math id="eq1">
  <semantics>
    <annotation-xml lang="en" encoding="application/xhtml+xml">
      <span><span id="eq1-p-s"><span id="eq1-p-e1"><span id="eq1-p-a1">Two</span> <span id="eq1-p-o1">plus</span> <span id="eq1-p-a2">two</span></span> <span id="eq1-p-o2">is</span> <span id="eq1-p-e2">four</span></span>.</span>
    </annotation-xml>
    <annotation-xml lang="fr" encoding="application/xhtml+xml">
      <span><span id="eq1-p-s-fr"><span id="eq1-p-e1-fr"><span id="eq1-p-a1-fr">Deux</span> <span id="eq1-p-o1-fr">plus</span> <span id="eq1-p-a2-fr">deux</span></span> <span id="eq1-p-o2-fr">c’est</span> <span id="eq1-p-e2-fr">quatre</span></span>.</span>
    </annotation-xml>
    <annotation-xml name="contentequiv" encoding="application/mathml-content+xml">
      <apply id="eq1-s-s"><eq id="eq1-s-o2" />
        <apply id="eq1-s-e1"><plus id="eq1-s-o1" /><cn id="eq1-s-a1">2</cn><cn id="eq1-s-a2">2</cn></apply>
        <cn id="eq1-s-e2">4</cn>
      </apply>
    </annotation-xml>
    <annotation-xml name="metadata" encoding="application/rdf+xml">
      <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
               xmlns:mm="http://example.com/math-metadata/">
        <rdf:Description rdf:about="eq1-p-s">
          <mm:mapsTo rdf:resource="eq1-s-s" />
        </rdf:Description>
        <rdf:Description rdf:about="eq1-p-o2">
          <mm:mapsTo rdf:resource="eq1-s-o2" />
        </rdf:Description>
        <rdf:Description rdf:about="eq1-p-e1">
          <mm:mapsTo rdf:resource="eq1-s-e1" />
        </rdf:Description>
        <rdf:Description rdf:about="eq1-p-e2">
          <mm:mapsTo rdf:resource="eq1-s-e2" />
        </rdf:Description>
        ...
        <rdf:Description rdf:about="eq1-p-s-fr">
          <mm:mapsTo rdf:resource="eq1-s-s" />
        </rdf:Description>
        <rdf:Description rdf:about="eq1-p-o2-fr">
          <mm:mapsTo rdf:resource="eq1-s-o2" />
        </rdf:Description>
        <rdf:Description rdf:about="eq1-p-e1-fr">
          <mm:mapsTo rdf:resource="eq1-s-e1" />
        </rdf:Description>
        <rdf:Description rdf:about="eq1-p-e2-fr">
          <mm:mapsTo rdf:resource="eq1-s-e2" />
        </rdf:Description>
        ...
      </rdf:RDF>
    </annotation-xml>
  </semantics>
</math>

MathML4 in HTML5 in MathML4

We can consider natural language content for expressions like: x plus y is z. The following example shows how such expressions can be represented utilizing MathML4 in HTML5 in MathML4.

<p>
  <span>This is a previous sentence.</span>
  <math>
    <semantics>
      <annotation-xml encoding="application/xhtml+xml">
        <span><math>{{x}}</math> plus <math>{{y}}</math> is <math>{{z}}</math>.</span>
      </annotation-xml>
      <annotation-xml name="contentequiv" encoding="application/mathml-content+xml">
        <apply><eq />
          <apply><plus /><ci>x</ci><ci>y</ci></apply>
          <ci>z</ci>
        </apply>
      </annotation-xml>
    </semantics>
  </math>
  <span>This is a next sentence.</span>
</p>

Conclusion

Some examples were indicated on the topics of natural language and mathematics which explore some of the reasons why it might be desirable to be able to style math elements to display presentation content in an inline manner, flowing with surrounding hypertext and wrapping lines.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HTML5 examples and the sections on MathML’s mtext, expression metadata, and MathML4 in HTML5. Compare the requested inline, wrapping behavior and semantic annotations against the MathML4 editors draft; done requires a scoped, agreed specification change or an explicit resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.