Class: Jekyll::Spaceship::MathjaxProcessor

Inherits:
Processor
  • Object
show all
Defined in:
lib/jekyll-spaceship/processors/mathjax-processor.rb

Instance Method Summary collapse

Methods inherited from Processor

#content_tag, #initialize, register, #register

Constructor Details

This class inherits a constructor from Jekyll::Spaceship::Processor

Instance Method Details

#on_posts_post_render(post) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/jekyll-spaceship/processors/mathjax-processor.rb', line 9

def on_posts_post_render(post)
  # use nokogiri to parse html
  doc = Nokogiri::HTML(post.output)

  params = "config=TeX-AMS-MML_HTMLorMML"
  src = "//cdn.mathjax.org/mathjax/latest/MathJax.js?#{params}"
  doc.at('head').add_child("<script src=\"#{src}\"></script>")

  post.output = doc.to_s
end