Module: Softcover::Mathjax
- Defined in:
- lib/softcover/mathjax.rb
Constant Summary collapse
- MATHJAX =
'MathJax/MathJax.js?config='
- AMS_HTML =
'/' + MATHJAX + 'TeX-AMS_HTML'
- AMS_SVG =
MATHJAX + 'TeX-AMS-MML_SVG'
Class Method Summary collapse
-
.config(options = {}) ⇒ Object
Returns the MathJax configuration.
-
.escaped_config ⇒ Object
Rerturns a version of the MathJax configuration escaped for the server.
Class Method Details
.config(options = {}) ⇒ Object
Returns the MathJax configuration.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/softcover/mathjax.rb', line 5 def self.config( = {}) chapter_number = if [:chapter_number] # Call .inspect.inspect to escape the chapter number # code for interpolation. [:chapter_number].inspect.inspect elsif [:chapter_number].nil? '#{chapter_number}' else # chapter_number is false, i.e., it's a single page false end fn = if chapter_number "formatNumber: function (n) { return #{chapter_number} + '.' + n }" else "" end <<-EOS MathJax.Hub.Config({ "HTML-CSS": { availableFonts: ["TeX"], }, TeX: { extensions: ["AMSmath.js", "AMSsymbols.js"], equationNumbers: { autoNumber: "AMS", #{fn} }, Macros: { PolyTeX: "Poly{\\\\TeX}", PolyTeXnic: "Poly{\\\\TeX}nic", #{custom_macros} } }, showProcessingMessages: false, messageStyle: "none", imageFont: null }); EOS end |
.escaped_config ⇒ Object
Rerturns a version of the MathJax configuration escaped for the server. There’s an extra interpolation somewhere between here and the server, which this method corrects for.
48 49 50 |
# File 'lib/softcover/mathjax.rb', line 48 def self.escaped_config self.config.gsub('\\', '\\\\\\\\') end |