Giter Club home page Giter Club logo

jekyll-katex-block's Introduction

jekyll-katex-block

KaTeX is the new development from Khan Academy for super fast mathematics typesetting on your website. It renders your equations into pure CSS and HTML using a small JS file, making it orders of magnitude faster than the mainstream alternative, MathJax.

This small plugin integrates KaTeX into your Jekyll website utilising Liquid blocks, so rendering an equation is as simple as writing {% latex %} equation {% endlatex %}. It is intended to be lightweight and add no appreciable compilation time to your site, even if you have many equations.

Because the KaTeX JavaScript is being run server-side through the execjs Ruby gem, you don't even need to include the KaTeX JS in the resulting web page, only the CSS and fonts!

Installation

To install it, copy katex_block.rb into the _plugins folder of your Jekyll project.

You can download the script directly by running

wget https://raw.githubusercontent.com/drewsberry/jekyll-katex-block/master/katex_block.rb
mv katex_block.rb /path/to/your/site/_plugins/

Or by cloning the whole repo and copying it across

git clone https://github.com/drewsberry/jekyll-katex-block.git
cp jekyll-katex-block/katex_block.rb /path/to/your/site/_plugins/

You also need the KaTeX CSS file, katex.min.css, and the KaTeX font files copied into your project. To download these and for more information, head over to KaTeX GitHub Page and the KaTeX source repo.

For a fully working example, check out the test directory. It contains a minimal working example of using the plugin.

Use

To use it in a post, wrap your equation in a latex block as follows:

{% latex %} E = mc^2 {% endlatex %}

And that's it!

If you also want to have centred equations, you can do:

{% latex centred %} E = mc^2 {% endlatex %}

It's really as simple as that. This is intended to be a virtually weightless extension to your Jekyll blog that allows you to leverage the virtually weightless KaTeX CSS for incredibly fast and easy mathematics typesetting.

Options

There is currently one global option, which is the relative path from the root of your Jekyll project to the KaTeX javascript file; you can change it in your config.yml like so:

katex:
    path_to_js: "./your/path/to/katex/js"

The default value is ./public/js/katex.min.js.

Problems

The only real problem is that being relatively new, KaTeX doesn't yet support all mathematical symbols that you might need. Several important PRs are in the works over at https://github.com/Khan/KaTeX/pulls, in particular #151 which adds vital symbols like \nabla, \imath, \hbar, \exists and a load of others.

jekyll-katex-block's People

Contributors

drewsberry avatar

Stargazers

Simon Strandgaard avatar ysmull avatar Morgan Gillis avatar Felix avatar Notas Hellout avatar Takamasa Oshikiri avatar Kevin Languasco avatar Sebastian Wilzbach avatar flyeven avatar Nicholas Rutherford avatar Yunior Rahmawan Usop avatar Francisco Lopes avatar Harry Gould avatar Justin Jaffray avatar Lambder avatar Zongkun Dou avatar

Watchers

James Cloos avatar  avatar  avatar

jekyll-katex-block's Issues

Jekyll 3.3.1 Unexpected character undefined

even the simplest inputs (in this case "x") result in the following:

jekyll 3.3.1 | Error:  ParseError: KaTeX parse error: Unexpected character: 'undefined' at position 0: ̲x

ReferenceError with latest Jekyll (2.5.3)

With Jekyll 2.5.3, I couldn't build the test site.

      Generating... 
  Liquid Exception: ReferenceError: Can't find variable: global in index.html
jekyll 2.5.3 | Error:  ReferenceError: Can't find variable: global

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.