For one of my upcoming posts, which I am currently using this post to procrastinate with, it will feature some equations.

These equations, due to their use of a wide range of symbols, will need to use some form of complex formatting.

I believe that markdown supports the ability to insert LaTeX mathematical typesetting; so this post is created to test this formatting.

The following equation, which I believe will feature in the upcoming post will be around the Navier-Stokes equation, more particularly those of the Reynolds-averaged Navier-Stokes equations.

The fortunate fact for the reader over here is that they did not have to go through the pain of actually attempting to do this.

All that the reader, yes you, reader, observes is a lovely formatted equation that simply appears on the screen.

However… It is never so simple, after having a look at how to format LaTeX equations on GitHub Pages, it is clear that the original vision of Markdown was a highly simplified use case where basic formatting tools can be used to create basic content…

So naturally, it became a little more complex than I wanted to generate the text.

Let me take you on a little journey, hopefully it will feel a bit less painful for you as I took one for the team.

Normally, with Markdown, I would be able to take the file, make use of my good friend Pandoc, and from there, it would create an intermediate file that converts the markdown into a .tex file, from there, the existing installation of TeX on my system would then be invoked to generate the final document (be it HTML, PDF, etc.)

However, when it comes to GitHub pages, it is mostly a black box; additionally, when one chooses to use such a system as I have done (which takes in markdown documents, which are then converted into HTML files that are served up to the browser), it becomes even more difficult to figure out what is happening behind the scenes. Too many points of failure, me thinks… A problem for another day maybe…

Let’s get back on track. It started, like most journeys with a visit to a GitHub issue ((which mostly begin with visits to stackoverflow)) here and to a lesser extent, here where I found that it may indeed be possible to generate LaTeX-style formulas in GitHub.

It appears as if, at some point, there were a couple of online services which provided the ability to convert LaTeX formatted equations into content that can be served by GitHub pages, however, those services are often half-baked and, in this case, were no longer operational…

Fortunately, I was able to find out how those tools worked: the quite simply formed a URL that was capable of being interpreted by the system (not sure if this is GitHub or the web browser) to show the equation formatted just as required.

The formatting begins with:

https://render.githubusercontent.com/render/math?math=

Which is then followed up by the content of the formatted LaTeX equation, of course the content needs to be encoded into URI encoding. So, out comes the Python script!!

Yeah, it is a super simple script, I won’t include it here, but it simply takes the plain text that would usually be taken by TeX, and converts it into the encoded format.

Now my URL looks like, well… I wouldn’t put you, dear reader, through that torture. Needless to say, it’s ugly.

Ugly, yes, I know. But when it works, you won’t see what’s happening behind the scenes.

From here, simply wrapping the URL into a figure environment (?) does the job.

![](https://render.githubusercontent.com/render/math?math=%24%20%5Crho%20u_j%20%5Cfrac%7B%5Cdelta%20u_i%7D%7B%5Cdelta%20x_j%7D%20%24)

There you have it, dear reader, you now know how the sausage is made!

I hope this has been worth your time. I will not admit how long it took to plug that entire equation in, I also don’t really like the not formatting used here…