An extension that handles TeX math rendering for your Flarum forum.
Click to view settings screenshot
- Based on KaTeX (the fastest math typesetting library on the web).
- Display expressions as an inline or a block element.
- Compatible with Markdown and BBCode.
- Almost fully customizable.
- Fully self-hosted.
Use Bazaar or install manually:
composer require the-turk/flarum-mathren
composer update the-turk/flarum-mathren
php flarum cache:clear
Enable the extension.
You can use unlimited set of delimiters through this extension. But choose them wisely. LaTeX originally uses $…$
for inline delimiters, but it ruins the display of normal $
in text as expected in forum environment. However, MathRen uses [math]...[/math]
for block and [imath]...[/imath]
for inline delimiters by default (could be changed from the settings page) and has nothing to do with special characters.
You will see two new definitions including Main BBCode delimiter and Alias delimiters on the settings page. Since we can't use Regex for a simple find and replace operation with obvious reasons (See more on here), additional delimiters are meant to be alias for main BBCode delimiters. If you have special delimiters (like $$
) in your alias delimiters list, MathRen will scan the whole post for additional (alias) delimiters when saving a post and will try to replace them with main BBCode delimiters. This may cause longer waiting time when saving a post. You may want to use additional BBCode delimiters instead of special ones to prevent this action though. Because additional BBCode delimiters won't be changed with main BBCode delimiters and will stay as it is in the abscence of special delimiters in alias delimiters list.
Wrap your TeX code with [math]
and [/math]
or your custom delimiters.
[math]\int_{-\infty}^\infty\hat\xi\,e^{2\pi i\xi x}\,d\xi[/math]
Block expressions will be wrapped with <span class="mathren-block">...</span>
by default.
Wrap your TeX code with [imath]
and [/imath]
or your custom delimiters.
Lorem ipsum dolor [imath]\varDelta = b^2-4ac[/imath] sit amet.
Inline expressions will be wrapped with <span class="mathren-inline">...</span>
by default.
If you're willing to show the TeX code with delimiters, there are two options:
- Wrap your expression with `backticks` or
code
tag.
- You must set it as an ignored tag from the settings page.
- Use a decisive keyword with your expressions.
- The keyword is
ignore
by default. But you can change it or assign multiple keywords from the settings page. You must write one of these keywords next to the special right delimiter (i.e.$$...$${keyword}
,\(...\){keyword}
) with curly brackets or inside a BBCode (i.e.[math=keyword]...[/math]
). Note that[math]%e%[/math]{keyword}
is an example of invalid usage.
These expressions won't be rendered:
`[math]\int_{-\infty}^\infty\hat\xi\,e^{2\pi i\xi x}\,d\xi[/math]`
[math=ignore]\int_{-\infty}^\infty\hat\xi\,e^{2\pi i\xi x}\,d\xi[/math]
[imath=ignore]\varDelta = b^2-4ac[/imath]
$$\int_{-\infty}^\infty\hat\xi\,e^{2\pi i\xi x}\,d\xi$${ignore}
\[\int_{-\infty}^\infty\hat\xi\,e^{2\pi i\xi x}\,d\xi\]{ignore}
\(\varDelta = b^2-4ac\){ignore}
Ignored expressions will be wrapped with <span class="{mathren-inline|mathren-block} mathren-ignore">...</span>
by default if you choose the second option.
English is not my mother tongue, i'll appreciate it if you correct my translations.