SMOLNET PORTAL home about changes
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>
      Re: Subscripts And Superscripts In Gemtext
    </title>
    <meta name="generator" content="//dj-chase.com/Make.py">
    <link rel="stylesheet" href="../style.css?cache-bust=2024-02-15">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <!-- whitespace to right of nav -->
    <nav>
      <a href="#start">Skip to start</a> <!-- screen-reader–only p -->
      <p>
        You are here:
      </p>
      <ol>
        <li>
          <a href="/" aria-label="home">⌂&nbsp;<span>›</span></a>
        </li>
        <li>
          <a href="/documents/">documents&nbsp;<span>›</span></a>
        </li>
        <li>
          <a href="/documents/re-sub-sup-gemtext.gmi">re-sub-sup-gemtext.gmi</a>
        </li>
      </ol>
    </nav>
    <main id="start">
      <h1>
        Re: Subscripts And Superscripts In Gemtext
      </h1>
      <p>
        <a href="gemini://gemi.dev/gemlog/2022-06-06-unicode-sub-sup.gmi">In reply to: Curiouser</a>
      </p>
      <p>
        Curiouser wrote:
      </p>
      <blockquote>
        Math formulas are especially challenging, not only because they can have so many symbols (such as sigma 'Σ'), but those symbols must be rendered in a certain layout (e.g. Σ used to sum a series has the variable and its starting value, as well as the value its going to, arranged in 2 different rows to the right of the Σ).
      </blockquote>
      <p>
        As a further example, sigma notation only behaves that way when it’s inline. ‘Block-level’ sigma notation places one row above the sigma and the other below, and makes the sigma like twice as large as the rest of the text. This holds true for a lot of other operations as well, such as integrals (∫), sequential products (∏), and sometimes unions (∪). Limits also follow the same rules, except they’re not extra-large because they don’t have their own symbol.
      </p>
      <blockquote>
        In fact, text layout of formulas and symbols is such a complicate domain that Donald Knuth literally created TeX, an entire digital typesetting system, while he was writing "The Art of Computer Programming."
      </blockquote>
      <blockquote>
        Given all this complexity, I didn't even try to represent math formulas in gemtext.
      </blockquote>
      <p>
        This is what made me reply to this post. You see, I quite like math, so I envision writing some here at times. So as part of working on the back-end, I needed to think about how to typeset math in Gemtext, and I think I’ve come up with a workable solution.
      </p>
      <p>
        Basically, we can use preformatted blocks to approximate block-level mathematics and put plaintext math using unicode’s extensive set of math symbols in the alt-text as a mostly accessible fallback.
      </p>
      <p>
        <mark><strong>Note</strong>: This is still not completely accessible, so it’s important to also provide an accessible format.</mark>
      </p>
      <h2>
        Examples
      </h2>
      <p>
        For these examples, I have put the alt text as the summary and a properly marked-up preformatted block in the details. This more closely resembles the Gemtext expirence.
      </p>
      <details>
        <summary>
          Σᵢ₌₃⁷ i²
        </summary>
        <pre role="img" alt="Above equation rendered in Unicode art">
 ₇
 Σ 𝑖²
ᶤ⁼³
</pre>
      </details>
      <hr class="light">
      <details>
        <summary>
          ∫ _(π/6) ^π sin θ dθ = [−cos θ] _(π/6) ^π = 1 + (√3)/2
        </summary>
        <pre role="img" alt="Above equations rendered in Unicode art">
 π
 ⌠               ⎡         ⎤ π
 ⌡  sin 𝜃 d𝜃  =  ⎢ − cos 𝜃 ⎥
π/6              ⎣         ⎦ π/6

                       √3
              =  1  +  ──
                       2
</pre>
      </details>
      <hr class="light">
      <details>
        <summary>
          Dₓ cos(xy) = Dₓ (1 + sin y)
        </summary>
        <pre role="img" alt="Above equation rendered using Unicode art">
     Dₓ cos(𝑥𝑦)  =  Dₓ (1 + sin 𝑦)
</pre>
      </details>
      <details>
        <summary>
          −sin(xy)yy' = y' cos y
        </summary>
        <pre role="img" alt="Above equation rendered using Unicode art">
     sin(𝑥𝑦)𝑦𝑦′
   − ──────────  =  1
      𝑦′ cos 𝑦
</pre>
      </details>
      <details>
        <summary>
          - ""[sin(xy)y / cos y]"" (y'/y') = 1
        </summary>
        <pre role="img" alt="Above equation rendered using Unicode art">
   sin(𝑥𝑦)𝑦  𝑦′
−  ────────  ──  =  1
    cos 𝑦    𝑦′
</pre>
      </details>
      <details>
        <summary>
          y' (1 × 1¹) = − cos y / [sin(xy)y]
        </summary>
        <pre role="img" alt="Above equation rendered using Unicode art">
                       cos 𝑦
    𝑦′ (1 × 1¹)  =  - ────────
                      sin(𝑥𝑦)𝑦
</pre>
      </details>
      <details>
        <summary>
          y' = − cos y / [sin(xy)y]
        </summary>
        <pre role="img" alt="Above equation rendered using Unicode art">
                       cos 𝑦
             𝑦′  =  - ────────
                      sin(𝑥𝑦)𝑦
</pre>
      </details><!-- html code generated by txt2tags 3.3 (http://txt2tags.org) -->
      <footer>
        <p>
          Questions, comments, or wrote a reply? <a href="mailto:u9000@posteo.mx">Email me</a>.
        </p>
        <p>
          ©&nbsp;DJ Chase 2023-11-21. Licensed under the Academic Free License (AFL&nbsp;3.0).
        </p>
        <p>
          <a href="/cgi-bin/cite.sh">Cite this page</a>
        </p>
        <p>
          <a href="https://u9.tel/gemtext-math">Short link</a>
        </p>
      </footer><!-- cmdline: txt2tags  -->
    </main>
  </body>
</html>
Response: 20 (Success), text/plain
Original URLgemini://dj-chase.com/documents/re-sub-sup-gemtext.html
Status Code20 (Success)
Content-Typetext/plain; charset=utf-8