Sha256: 13c96cc6b75ce38186bf6f74b970279d7c291504cbf7877e39aad57364b3bb94
Contents?: true
Size: 753 Bytes
Versions: 4
Compression:
Stored size: 753 Bytes
Contents
# frozen_string_literal: true require 'execjs' require 'liquid/tag/parser' module Jekyll module Tags # LaTeX tag, HTML rendering via KaTeX class LatexBlock < Liquid::Block def initialize(tag_name, markup, options) @parsed_options = Liquid::Tag::Parser.new(markup).args super end def katex_js # rubocop:disable Style/ClassVars @@katex ||= ExecJS.compile(File.read(katex_path)) # rubocop:enable Style/ClassVars end def katex_path File.expand_path('../../js/katex.js', File.dirname(__FILE__)) end def render(context) latex_source = super katex_js.call('katex.renderToString', latex_source, @parsed_options) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems