Adaptation to MathJax
This commit is contained in:
parent
f67b94ffa6
commit
d576a915a8
3 changed files with 16 additions and 1 deletions
1
Rules
1
Rules
|
@ -45,6 +45,7 @@ compile '/html/*' do
|
||||||
elsif ext == 'md' || ext == 'markdown'
|
elsif ext == 'md' || ext == 'markdown'
|
||||||
filter :erb
|
filter :erb
|
||||||
filter :kramdown
|
filter :kramdown
|
||||||
|
filter :math_repair # after kramdown
|
||||||
else
|
else
|
||||||
raise "Filter is not configured for #{item.identifier} in Rules file."
|
raise "Filter is not configured for #{item.identifier} in Rules file."
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ conf=LocalConf.new
|
||||||
language=@item_rep.path.sub(/\/Scratch\//,'').sub(/\/.*$/,'')
|
language=@item_rep.path.sub(/\/Scratch\//,'').sub(/\/.*$/,'')
|
||||||
conf.language=language
|
conf.language=language
|
||||||
|
|
||||||
containMaths=yield.match('class="math"')
|
containMaths=yield.match(/$(.|\n)*$/)
|
||||||
conf.containMaths=containMaths
|
conf.containMaths=containMaths
|
||||||
|
|
||||||
# the current item is an article
|
# the current item is an article
|
||||||
|
|
14
lib/y.rb
14
lib/y.rb
|
@ -20,6 +20,20 @@ def allExceptCode( f, content )
|
||||||
end
|
end
|
||||||
|
|
||||||
module Nanoc3::Filters
|
module Nanoc3::Filters
|
||||||
|
class MathJaxKramdownRepair < Nanoc3::Filter
|
||||||
|
identifiers :math_repair
|
||||||
|
|
||||||
|
def description(content)
|
||||||
|
content.gsub(/<div class="math">(.+?)<\/div>/m) do
|
||||||
|
return %{$$ #{$1} $$}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def run(content, params={})
|
||||||
|
allExceptCode( :description , content )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Description < Nanoc3::Filter
|
class Description < Nanoc3::Filter
|
||||||
identifiers :description
|
identifiers :description
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue