Class: Daimon::Markdown::Plugin::Math
- Defined in:
- lib/daimon/markdown/plugin/math.rb
Instance Attribute Summary
Attributes inherited from Base
#context, #doc, #node, #result
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Daimon::Markdown::Plugin::Base
Class Method Details
.script_tag ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/daimon/markdown/plugin/math.rb', line 7 def self.script_tag tag = " <script type=\"text/x-mathjax-config\">\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [['$','$']]},\n asciimath2jax: {delimiters: [['`', '`']]},\n TeX: {extensions: [\"mhchem.js\"]}\n });\n </script>\n <script type=\"text/javascript\"\n async\n src=\"https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_CHTML\">\n </script>\n TAG\n if tag.respond_to?(:html_safe)\n tag.html_safe\n else\n tag\n end\nend\n" |
Instance Method Details
#call(expression) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/daimon/markdown/plugin/math.rb', line 28 def call(expression) if expression.start_with?("$$") node.parent.replace(%Q(<div class="math">#{expression}</div>)) else result[:plugins] << expression end end |