Test of code & maths in WordPress

Test of maths and code in WordPress.

Code

Default code block

This is a default code block
No language formatting
No line numbering

Enlighter code block

Has syntax highlighting (but not for Julia), but font size is totally off. Looks crap.

def my_func(x):
    print(x*2)

Markdown

Below is a markdown block. I wonder if I can add code in here?

def my_func(x):
    print(2x)

Yes. This looks much better, but it isn’t applying any code formatting even is using the ```python syntax.

Maths – with KaTeX plugin

It’s not as easy as markdown or LaTeX, but you can get equations working, including inline equations.

Below is is a KaTeX block. You create a shortcode block then enter equation like this:

[katex]
y = \beta_0 + \beta_1 x
[/katex]
<br /> y = \beta_0 + \beta_1 x<br />

What about inline equations? Test using the following line in a plain text block.

This is an inline equation [latex]e = mc^2[/latex].

This is an inline equation e = mc^2.