(function($){ChiliBook={version:"1.8b",automatic:true,automaticSelector:"code",codeLanguage:function(el){var recipeName=$(el).attr("class");return recipeName?recipeName:''},metadataSelector:"object.chili",recipeLoading:true,recipeFolder:"",stylesheetLoading:true,stylesheetFolder:"",defaultReplacement:'$$',replaceSpace:" ",replaceTab:"    ",replaceNewLine:" 
",recipes:{},queue:{},preFixCopy:document.selection&&document.selection.createRange,preContent:"",preElement:null};$.metaobjects=function(options){options=$.extend({context:document,clean:true,selector:'object.metaobject'},options);function jsValue(value){eval('value = '+value+";");return value}return $(options.selector,options.context).each(function(){var settings={target:this.parentNode};$('> param[@name=metaparam]',this).each(function(){$.extend(settings,jsValue(this.value))});$('> param',this).not('[@name=metaparam]').each(function(){var name=this.name,value=jsValue(this.value);$(settings.target).each(function(){this[name]=value})});if(options.clean){$(this).remove()}})};$.fn.chili=function(options){var book=$.extend({},ChiliBook,options||{});function cook(ingredients,recipe){function prepareStep(stepName,step){var exp=(typeof step.exp=="string")?step.exp:step.exp.source;steps.push({stepName:stepName,exp:"("+exp+")",length:1+(exp.replace(/\\./g,"%").replace(/\[.*?\]/g,"%").match(/\((?!\?)/g)||[]).length,replacement:(step.replacement)?step.replacement:book.defaultReplacement})}function knowHow(){var prevLength=0;var exps=new Array;for(var i=0;i1){return}var ingredients=el.childNodes[0]&&el.childNodes[0].data;if(!ingredients){return}ingredients=ingredients.replace(/\r\n?/g,"\n");var dish=cook(ingredients,recipe);if(book.replaceTab){dish=dish.replace(/\t/g,book.replaceTab)}if(book.replaceNewLine){dish=dish.replace(/\n/g,book.replaceNewLine)}$(el).html(dish);if(ChiliBook.preFixCopy){$(el).parents().filter("pre").bind("mousedown",function(){ChiliBook.preElement=this}).bind("mouseup",function(){if(ChiliBook.preElement==this){ChiliBook.preContent=document.selection.createRange().htmlText}})}}function getPath(recipeName,options){var settingsDef={recipeFolder:book.recipeFolder,recipeFile:recipeName+".js",stylesheetFolder:book.stylesheetFolder,stylesheetFile:recipeName+".css"};var settings;if(options&&typeof options=="object"){settings=$.extend(settingsDef,options)}else{settings=settingsDef}return{recipe:settings.recipeFolder+settings.recipeFile,stylesheet:settings.stylesheetFolder+settings.stylesheetFile}}if(book.metadataSelector){$.metaobjects({context:this,selector:book.metadataSelector})}$(this).each(function(){var el=this;var recipeName=book.codeLanguage(el);if(''!=recipeName){var path=getPath(recipeName,el.chili);if(book.recipeLoading||el.chili){if(!book.queue[path.recipe]){try{book.queue[path.recipe]=[el];$.getJSON(path.recipe,function(recipeLoaded){recipeLoaded.path=path.recipe;book.recipes[path.recipe]=recipeLoaded;if(book.stylesheetLoading){checkCSS(path.stylesheet)}var q=book.queue[path.recipe];for(var i=0,iTop=q.length;i-1);text=text.replace(/\]*?\>/ig,newline_flag);var el=document.createElement('
');el.innerHTML=text;text=el.innerText.replace(new RegExp(newline_flag,"g"),'\r\n');return text}$("body").bind("copy",function(){if(''!=ChiliBook.preContent){window.clipboardData.setData('Text',preformatted(ChiliBook.preContent));event.returnValue=false}}).bind("mousedown",function(){ChiliBook.preContent=""}).bind("mouseup",function(){ChiliBook.preElement=null})}})})(jQuery);