# All files in the 'lib' directory will be loaded # before nanoc starts compiling. def allExceptCode( f, content ) regexp=/]*>.*?<\/code>/m tmp="" mem=[] content.scan(regexp).each do |c| mem <<= c end i=0 content.split(regexp).each do |x| tmp <<= send(f,x) if not mem[i].nil? tmp <<= mem[i] i+=1 end end tmp end module Nanoc3::Filters class MathJaxKramdownRepair < Nanoc3::Filter identifiers :math_repair def description(content) content.gsub(/
(.+?)<\/div>/m) do return %{$$ #{$1} $$} end end def run(content, params={}) allExceptCode( :description , content ) end end class Description < Nanoc3::Filter identifiers :description def description(content) content.gsub(/^\s*]*)?>(.+?)<\/desc>/m) do n=0 if $1 then summary=$1 summary.slice!(0) else summary="no description" end '
'+$2.gsub(/([^:]+):(.+?)::/m) do n+=1 if n % 2 == 0 sombre=' class="assombris10"' else sombre=' class="assombris20"' end '' end+'
'+$1+''+$2+'
' end end def run(content, params={}) allExceptCode( :description , content ) end end class FrenchSpace < Nanoc3::Filter identifiers :frenchspace def ameliorate(content) content.gsub(/ ([:;!?]|&eq;|≠)/) { " "+$1 } end def run(content, params={}) allExceptCode( :ameliorate, content ) end end class Footnotes < Nanoc3::Filter identifiers :footnotes def hr_before_footnote(content) content.gsub(/
/) { %{
#{$&}} } end def run(content, params={}) allExceptCode( :hr_before_footnote, content ) end end class FirstHierarchy < Nanoc3::Filter identifiers :firsthi def run(content, params={}) content.gsub(/\A(\s|\n)*]*class="corps"[^>]*>(\s)*(.*?)<\/sc>/m) do %{}+$1+%{} end.gsub(/''(.*?)''/m)do %{}+$1+%{} end.gsub(/\(c\)/) do %{©} end.gsub(/\(r\)/) do %{®} end.gsub(/-(>|>)/) do %{→} end.gsub(/(<|<)-/) do %{←} end end def run(content, params={}) allExceptCode( :ytypofunc, content ) end end class YAbbreviations < Nanoc3::Filter identifiers :yabbreviations def makeabbreviations(text) { 'WebDav' => 'Web-based Distributed Authoring and Versionning', 'cms' => 'Content Management System', 'xml' => 'eXtended Markup Language', }.each do |keyword,abbreviation| text=text.gsub(/\b#{keyword}\b/i) do %{#{keyword}} end end return text end def run(content, params={}) allExceptCode(:makeabbreviations, content ) end end class MultiCorps < Nanoc3::Filter identifiers :multicorps def run(content, params={}) content.gsub(/^.*newcorps.*$/) do %{\n
\n\n
\n} end.gsub(/^.*begindiv\((.*)\).*$/) do %{\n
\n} end.gsub(/^.*enddiv.*$/) do %{\n
\n} end end end end def block(title, url, text, position="left") return %{} end