
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
We are living in an age, where displaying math on web pages is never hard, thanks to the great work of MathJax.
To quote the description from its official website,
MathJax is an open source JavaScript display engine for mathematics that works in all modern browsers.
No more setup for readers. No more browser plugins. No more font installations… It just works.
Integrating MathJax into a rails project however could be a pain. MathJax is HUGE. It makes your project folder swollen very much, because of the excessive amount of files contained in this package. Including mathjax inside your developing directory makes your TextMate less responsive, because when TextMate loses focus and then regains focus, it will scan the whole directory structure for change.
Another problem is, where to put? Put into public
does not seem the best practice, since beginning with rails 3.1 public
is by default ignored in production environment. Plus it is big, when using git, it leaves you no choice but to throw mathjax inside .gitignore, which makes sharing across developers less painless.
That's the time when mathjax-rails comes into play!
We maintain mathjax-rails to always use the latest version of stable MathJax realeases.
To see the actual version, check the constant Mathjax::Rails::MATHJAXVERSION.
add this line to your Gemfile
gem 'mathjax-rails'
then
$ bundle install
The new gem is more recently mentained.Thank you Manu S Ajith.
A Ruby gem for including mathjax for Rails 3.x or above apps
Add this line to your application's Gemfile:
gem 'mathjax-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mathjax-rails
add the following to config/routes.rb (you can change the name of course)
mathjax 'mathjax'
add the script tag inside app/views/layouts/application.html.erb
<%= mathjax_tag %>
and it is done!
To try it, write a simple formula, for example,
\[\int_a^b f(x) dx=F(b)-F(a)\]
By default the TeX-AMS_HTML-full.js
is loaded as the configuration file.
If you do not want any configuration file to be loaded:
<%= mathjax_tag :config=>false %>
If you want to load another configuration file, say Accessible-full.js
:
<%= mathjax_tag :config=>'Accessible-full.js' %>
Additional configuration can be added directly before mathjax_tag, for example:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'] ],
processEscapes: true
}
});
</script>
<%= mathjax_tag %>
For more options please consult the MathJax documentation.
Three simple things: it adds 1 controller MathjaxRailsController
; 1 helper method mathjax_tag
; 1 router method mathjax
.
It won't pollute your rails project more than the above three.
If you have a fast CDN service at hand, you don't need this gem.
Putting your MathJax at CDN is probably the best choice.
By dmarczal
,
To work in rails 3.1 on production environment wih ngnix I just comment the follow line in production.rb
#config/environments/production.rb
#config.action_dispatch.x_sendfile_header = "X-Sendfile"
2013.11.21 Added support for Rails 4 apps.
2011.7.28
Version 0.0.2 used to fail on Heroku. Now the problem is fixed. I used to use send_file
without content_type, which causes a failure when deployed to Heroku. Now in version 0.0.3 I use render :type=>...,
with the appropriate content-type set and the problem is solved.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that mathjax-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.