linjer / jekyll-katex

[DEPRECATED] Jekyll plugin for easy server-side math rendering via KaTeX
MIT License
96 stars 8 forks source link

Add support for macro option in rendering_options #34

Closed hrjakobsen closed 3 years ago

hrjakobsen commented 3 years ago

As discussed in #16 the option to add custom macros would be helpful. I've simply added the macro object to the rendering_options as specified at https://katex.org/docs/next/options.html.

Following the example provided at the link above, the configuration:

katex:
  rendering_options:
    macros: 
      "\\RR": "\\mathbb{R}"

Gives the ability to write

{% katex display %}
\RR
{% endkatex %}

For the following output image

Arguments are also supported. E.g.

katex:
  rendering_options:
    macros: 
      "\\RRArg": "\\mathbb{#1}"

and

{% katex display %}
\RRArg{R}
{% endkatex %}

Results in the same output.