Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/_plugins/jekyll-mathjax.rb
1677 views
1
Jekyll::Hooks.register :pages, :post_init do |page|
2
page.data['js_requirements'] = {
3
'mathjax' => page.content =~ /\$\$/ || page.content =~ /\\\(/,
4
'mermaid' => page.content =~ /```mermaid/ || page.content =~ /pre class="mermaid"/ || page.data['layout'] == 'workflow-list',
5
}
6
7
# some fixes for mathjax: escape underscores
8
# both in inline mode \\( .. \\) and block mode $$ ..$$
9
if page.content
10
page.content = page.content.gsub(/\$\$(.*?)\$\$/) { |m| m.gsub('_', '\\\\_') }
11
page.content = page.content.gsub(/\\\\\((.*?)\\\\\)/) { |m| m.gsub('_', '\\\\_') }
12
13
end
14
end
15
16