Skip to content

Use MathML for math formatting#155

Draft
MatthijsBlom wants to merge 7 commits intolearnyouahaskell:mainfrom
MatthijsBlom:math-formatting
Draft

Use MathML for math formatting#155
MatthijsBlom wants to merge 7 commits intolearnyouahaskell:mainfrom
MatthijsBlom:math-formatting

Conversation

@MatthijsBlom
Copy link
Copy Markdown
Contributor

@MatthijsBlom MatthijsBlom commented Apr 8, 2026

For now this is only a proof of concept.
If this direction is appreciated, I might look into it further.

To Do:

  • test on a variety of clients
  • find a more suitable math font
Before After

@pierluc-codes
Copy link
Copy Markdown
Collaborator

I like it!

For few second, I was hesitant because the previous syntax was closer to code. But, we are talking math, so the visual make sense.

If you can upload it somewhere, I can test on my iDevice and check if render similar.

Thanks!

Copy link
Copy Markdown
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution, thanks!

Small comments inline.

Comment thread source_md/recursion.md Outdated
For instance, the fibonacci sequence is defined recursively.
First, we define the first two fibonacci numbers non-recursively.
We say that *F(0) = 0* and *F(1) = 1*, meaning that the 0th and 1st fibonacci numbers are 0 and 1, respectively.
We say that $F(0) = 0$ and $F(1) = 1$, meaning that the 0<sup>th</sup> and 1<sup>st</sup> fibonacci numbers are $0$ and $1$, respectively.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a Pandoc option for superscripts: https://pandoc.org/MANUAL.html#extension-superscript-subscript

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so that's why there were these paired ^s in the polynomials.

Comment thread source_md/starting-out.md
If you evaluate that by typing out `triangles` in GHCi, you'll get a list of all possible triangles with sides under or equal to 10.
Next, we'll add a condition that they all have to be right triangles.
We'll also modify this function by taking into consideration that side *a* isn't larger than the hypotenuse and that side *b* isn't larger than side *a*.
We'll also modify this function by taking into consideration that side $a$ isn't larger than the hypotenuse and that side $b$ isn't larger than side $a$.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a good reason to switch from * to $? the former looks simpler to me and I naturally prefer simpler approaches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this one is really up to personal preferences.

## Function composition {#composition}

In mathematics, function composition is defined like this: ![ (f . g)(x) = f(g(x))](assets/images/higher-order-functions/composition.png), meaning that composing two functions produces a new function that, when called with a parameter, say, *x* is the equivalent of calling *g* with the parameter *x* and then calling the *f* with that result.
In mathematics, function composition is defined like this: $\left( f \circ g \right) (x) = f \left( g(x) \right)$, meaning that composing two functions produces a new function that, when called with an argument, say, $x$ is the equivalent of calling $g$ with the argument $x$ and then calling the $f$ with that result.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need to use \left and \right in these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but it looks slightly nicer:
image
Though still not as nice as I'd like. Ideally, the parentheses would share a horizontal symmetry access, and the bigger ones would therefore cross the baseline.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer same-sized parenthesis for expressions as simple as these for uniformity sake. I only resort to \left and \right when the expressions are big and it's hard to match the parenthesis. But I don't feel too strong about it in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants