# Jekyll Liquid Problem with a Mathjax Expression

There is a particular Mathjax expression which chokes when I build Github Pages using Mathjax

Use the expression $g^{\frac {p-1} {{p_i}^{n_i}}\$ in a github page where you import Mathjax. The page errors out while building.
This is the build error I get.

github-pages 227 | Error:  Liquid syntax error (line 3): Variable '{{p_i}' was not properly terminated with regexp: /\}\}/


I use Jekyll Now

I opened an issue with Mathjax - Github Mathjax chokes on the expression $g^{\frac {p-1} {{p_i}^{n_i}}}$ · Issue #2971 · mathjax/MathJax · GitHub

But they said it’s an issue with the Liquid Template of Jekyll

As you point out, this is a build issue; MathJax isn’t involved until the page is viewed in a browser, so it is not a MathJax problem, and there is nothing MathJax can do about it.

It appears that the Liquid Template for GitHub pages uses {{ variable }} to insert the value of a variable into your output, so that is conflicting with the use of braces in LaTeX notation. The {{ at the beginning of {{p_i}... is being picked up by the Liquid template as an attempted variable reference that isn’t closed properly by }} since the next brace is a single brace. You will need to either protect the braces in the math (perhaps via \{) or do something like insert spaces so that you have { { rather than {{ (I haven’t tested either of those suggestions).

In any case, it is something that must be dealt with at the template level, as it occurs long before MathJax itself is involved.

I tried opening an issue in Jekyll, but the Submit button remains greyed out even if I have filled all fields.

There are probably quite a few ways to accomplish this, but here are two that came to mind, which I tested and they work:

• Assigning and then displaying a variable
• Raw template tag

However, I will point out, I do not know MathJax and have not tested that element for the code I am sharing. Hopefully, this provides your solution or at least some inspiration

## Assigning and then displaying a variable

In this example, you will assign a variable with the formula you want to display on the page:

{% assign mj = '$g^{\frac {p-1} {{p_i}^{n_i}}\$' %}
{{mj}}


Output

$g^{\frac {p-1} {{p_i}^{n_i}}\$


I used the variable mj, but you can call it whatever you want. Also, if you have multiple formulas to display on a page, you can reuse the variable name like this:

Here is a formula that you should be aware of:
{% assign mj = '$g^{\frac {p-1} {{p_i}^{n_i}}\$' %}
{{mj}}

And here is another formula you should be aware of:
{% assign mj = '$g^{\div {p-1} {{p_i}^{n_i}}\$' %}
{{mj}}


Output

Here is a formula that you should be aware of:
$g^{\frac {p-1} {{p_i}^{n_i}}\$

And here is another formula you should be aware of:
$g^{\div {p-1} {{p_i}^{n_i}}\$


## Raw template tag

In this example, you will use the Liquid raw tag to display your function. The nice thing about this option is you do not have to do as much coding to assign variables. I do not use this tag on my sites, so my suggestion is to make sure it displays properly within your theme. If it does display properly, this is probably what I would use over assigning a variable.

Here is a formula:

{% raw %}
$g^{\frac {p-1} {{p_i}^{n_i}}\$
{% endraw %}


Output

Here is a formula:
$g^{\frac {p-1} {{p_i}^{n_i}}\$


## Reference

The raw tag is a Liquid template tag. If my examples are not exactly what you want, check out the documentation to see if there are other options that might be suitable for your situation:

As I have already mentioned in my bug description, I know a workaround & have mentioned the workaround. My point in posting this here is to get the Liquid bug fixed. I first tried to open an issue on jekyll github but I don’t seem to be able to do that. Even after filling all the elements of the Issue form, my submit button remains grayed out.

Unfortunately, I am not someone that manages the Jekyll project. I am however, a person that likes to freely help people when I have the time and knowledge to help. The title and the content of your question suggested you (a) can’t perform a certain function and (b) cannot submit an issue. I was trying to help you with (a).

That said, I am not sure opening an issue that attempts to change Jekyll’s code-recognition of double-brackets will make it too far.

Perhaps this will fix your issue?

Hello,
I am one of the maintainers of the Jekyll repository.

The primary issue here is definitely the presence of {{ that gets picked up by Jekyll’s template engine, Liquid.
This is not a bug, but simply a side-effect. The only solution is to work around the muddy area.

Even if you were to file at ticket at GitHub, the response would remain the same: work around the obstacle.

Like @BillRaymond suggested, the workarounds primarily consist of using {% raw %} ... {% endraw %} wherever one would have {{ or {% or their closing counterparts to be escaped / overlooked by Liquid.

One additional workaround is to declare render_with_liquid: false in the front matter to disable Liquid processing for the entire file.

A

Thank you both the render_with_liquid & @BillRaymond’s “raw” workaround are great considering that this is not a bug.

Thank you both of you.