UNPKG

elasticlunr

Version:

Lightweight full-text search engine in Javascript for browser search and offline search.

526 lines (495 loc) 27.5 kB
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" charset="utf-8"> <title>elasticlunr</title> <link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css"> <link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/bootstrap-responsive.css"> <link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/docs.css"> <style> body > .navbar .brand { float:left; text-shadow: rgba(255, 255, 255, 0.0980392) 0px 1px 0px, rgba(255, 255, 255, 0.4) 0px 0px 30px; color: white; margin-left:0px; font-weight:normal; } .bs-docs-sidenav.affix { box-shadow: 0 0 20px 1px rgba(0, 0, 0, 0.5); z-index: 10; } .bs-docs-sidenav i{ width: 8px; height: 8px; padding: 0px; margin: 0px; display: inline-block; margin-right:0.5em; } .bs-docs-sidenav > li > a { word-wrap: break-word; } .bs-docs-sidenav > li:first-child > a { border-top-right-radius: 6px; border-top-left-radius: 6px; } code[class*="language-"],pre[class*="language-"]{color:black;text-shadow:0 1px white;font-family:Consolas,Monaco,'Andale Mono',monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*="language-"]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*="language-"],pre[class*="language-"]{background:#f5f2f0}:not(pre)>code[class*="language-"]{padding:.1em;border-radius:.3em}.token.comment,.token.prolog,.token.doctype,.token.cdata{color:slategray}.token.punctuation{color:#999}.namespace{opacity:.7}.token.property,.token.tag,.token.boolean,.token.number{color:#905}.token.selector,.token.attr-name,.token.string{color:#690}.token.operator,.token.entity,.token.url,.language-css .token.string,.style .token.string{color:#a67f59;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.regex,.token.important{color:#e90}.token.important{font-weight:bold}.token.entity{cursor:help} div.description {margin: 14px 0; padding-top: 14px; border-bottom:1px solid #eee; } .tags {} .ctx-type { display:inline-block; margin-right:0.5em; //- float:right; margin-top:8px } footer iframe{vertical-align:middle;} </style> </head> <body data-spy="scroll" data-target=".scrollspy"> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"><a class="brand">Doxx</a> <div class="nav-collapse collapse"> <ul class="nav pull-right sponsored"></ul> </div> </div> </div> </div> <header id="overview" class="jumbotron subhead"> <div class="container"> <h1>elasticlunr</h1> <p class="lead"></p> </div> </header> <div class="container"> <div class="row"> <div class="span3 bs-docs-sidebar"> <ul class="nav nav-list bs-docs-sidenav affix-top"> <li><a href="index.html">Main</a></li> <li><a href="configuration.js.html">configuration.js</a></li> <li><a href="document_store.js.html">document_store.js</a></li> <li><a href="elasticlunr.js.html">elasticlunr.js</a></li> <li><a href="event_emitter.js.html">event_emitter.js</a></li> <li><a href="index.js.html">index.js</a></li> <li><a href="inverted_index.js.html">inverted_index.js</a></li> <li><a href="pipeline.js.html">pipeline.js</a></li> <li class="active"><a href="sorted_set.js.html">sorted_set.js</a></li> <li><a href="stemmer.js.html">stemmer.js</a></li> <li><a href="stop_word_filter.js.html">stop_word_filter.js</a></li> <li><a href="tokenizer.js.html">tokenizer.js</a></li> <li><a href="trimmer.js.html">trimmer.js</a></li> <li><a href="utils.js.html">utils.js</a></li> </ul> <div class="scrollspy"> <ul class="nav nav-list bs-docs-sidenav affix-top"> <li><a href="#SortedSet"><i class="alert alert-success"></i><span>SortedSet</span></a> </li> <li><a href="#load"><i class="alert alert-info"></i><span>load</span></a> </li> <li><a href="#add"><i class="alert alert-info"></i><span>add</span></a> </li> <li><a href="#toArray"><i class="alert alert-info"></i><span>toArray</span></a> </li> <li><a href="#map"><i class="alert alert-info"></i><span>map</span></a> </li> <li><a href="#forEach"><i class="alert alert-info"></i><span>forEach</span></a> </li> <li><a href="#indexOf"><i class="alert alert-info"></i><span>indexOf</span></a> </li> <li><a href="#locationFor"><i class="alert alert-info"></i><span>locationFor</span></a> </li> <li><a href="#intersect"><i class="alert alert-info"></i><span>intersect</span></a> </li> <li><a href="#clone"><i class="alert alert-info"></i><span>clone</span></a> </li> <li><a href="#union"><i class="alert alert-info"></i><span>union</span></a> </li> <li><a href="#toJSON"><i class="alert alert-info"></i><span>toJSON</span></a> </li> </ul> </div> </div> <div class="span9"> <div class="description"><p>sorted_set.js is added only to make elasticlunr.js compatible with lunr-languages.<br />if elasticlunr.js support different languages by default, this will make elasticlunr.js<br />much bigger that not good for browser usage.</p> </div> <section id="SortedSet"> <h1>SortedSet</h1> <h5 class="subheader"></h5> <p> <div class="label label-success radius ctx-type">constructor</div><span>lunr.SortedSet()</span> </p> </section> <div class="description"><p>lunr.SortedSets are used to maintain an array of uniq values in a sorted<br />order.</p> </div> <pre><code class="language-javascript">lunr.SortedSet = function () { this.length = 0 this.elements = [] }</code></pre> <section id="load"> <h1>load</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.load()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>serialisedData</td> <td>Array</td> <td><p>The serialised set to load.</p></td> </tr> </tbody> </table> <div class="description"><p>Loads a previously serialised sorted set.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.load = function (serialisedData) { var set = new this set.elements = serialisedData set.length = serialisedData.length return set }</code></pre> <section id="add"> <h1>add</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.add()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>The</td> <td>Object</td> <td><p>objects to add to this set.</p></td> </tr> </tbody> </table> <div class="description"><p>Inserts new items into the set in the correct position to maintain the<br />order.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.add = function () { var i, element for (i = 0; i &lt; arguments.length; i++) { element = arguments[i] if (~this.indexOf(element)) continue this.elements.splice(this.locationFor(element), 0, element) } this.length = this.elements.length }</code></pre> <section id="toArray"> <h1>toArray</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.toArray()</span> </p> </section> <div class="description"><p>Converts this sorted set into an array.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.toArray = function () { return this.elements.slice() }</code></pre> <section id="map"> <h1>map</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.map()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>fn</td> <td>Function</td> <td><p>The function that is called on each element of the set.</p></td> </tr> <tr> <td>ctx</td> <td>Object</td> <td><p>An optional object that can be used as the context for the function fn.</p></td> </tr> </tbody> </table> <div class="description"><p>Creates a new array with the results of calling a provided function on every<br />element in this sorted set.</p><p>Delegates to Array.prototype.map and has the same signature.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.map = function (fn, ctx) { return this.elements.map(fn, ctx) }</code></pre> <section id="forEach"> <h1>forEach</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.forEach()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>fn</td> <td>Function</td> <td><p>The function that is called on each element of the set.</p></td> </tr> <tr> <td>ctx</td> <td>Object</td> <td><p>An optional object that can be used as the context</p></td> </tr> </tbody> </table> <div class="description"><p>Executes a provided function once per sorted set element.</p><p>Delegates to Array.prototype.forEach and has the same signature.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.forEach = function (fn, ctx) { return this.elements.forEach(fn, ctx) }</code></pre> <section id="indexOf"> <h1>indexOf</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.indexOf()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>elem</td> <td>Object</td> <td><p>The object to locate in the sorted set.</p></td> </tr> </tbody> </table> <div class="description"><p>Returns the index at which a given element can be found in the<br />sorted set, or -1 if it is not present.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.indexOf = function (elem) { var start = 0, end = this.elements.length, sectionLength = end - start, pivot = start + Math.floor(sectionLength / 2), pivotElem = this.elements[pivot] while (sectionLength &gt; 1) { if (pivotElem === elem) return pivot if (pivotElem &lt; elem) start = pivot if (pivotElem &gt; elem) end = pivot sectionLength = end - start pivot = start + Math.floor(sectionLength / 2) pivotElem = this.elements[pivot] } if (pivotElem === elem) return pivot return -1 }</code></pre> <section id="locationFor"> <h1>locationFor</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.locationFor()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>elem</td> <td>Object</td> <td><p>The elem to find the position for in the set</p></td> </tr> </tbody> </table> <div class="description"><p>Returns the position within the sorted set that an element should be<br />inserted at to maintain the current order of the set.</p><p>This function assumes that the element to search for does not already exist<br />in the sorted set.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.locationFor = function (elem) { var start = 0, end = this.elements.length, sectionLength = end - start, pivot = start + Math.floor(sectionLength / 2), pivotElem = this.elements[pivot] while (sectionLength &gt; 1) { if (pivotElem &lt; elem) start = pivot if (pivotElem &gt; elem) end = pivot sectionLength = end - start pivot = start + Math.floor(sectionLength / 2) pivotElem = this.elements[pivot] } if (pivotElem &gt; elem) return pivot if (pivotElem &lt; elem) return pivot + 1 }</code></pre> <section id="intersect"> <h1>intersect</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.intersect()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>otherSet</td> <td>lunr.SortedSet</td> <td><p>The set to intersect with this set.</p></td> </tr> </tbody> </table> <div class="description"><p>Creates a new lunr.SortedSet that contains the elements in the intersection<br />of this set and the passed set.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.intersect = function (otherSet) { var intersectSet = new lunr.SortedSet, i = 0, j = 0, a_len = this.length, b_len = otherSet.length, a = this.elements, b = otherSet.elements while (true) { if (i &gt; a_len - 1 || j &gt; b_len - 1) break if (a[i] === b[j]) { intersectSet.add(a[i]) i++, j++ continue } if (a[i] &lt; b[j]) { i++ continue } if (a[i] &gt; b[j]) { j++ continue } }; return intersectSet }</code></pre> <section id="clone"> <h1>clone</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.clone()</span> </p> </section> <div class="description"><p>Makes a copy of this set</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.clone = function () { var clone = new lunr.SortedSet clone.elements = this.toArray() clone.length = clone.elements.length return clone }</code></pre> <section id="union"> <h1>union</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.union()</span> </p> </section> <table class="table table-bordered table-striped"> <thead> <tr> <th style="width:20%">Option name</th> <th style="width:20%">Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>otherSet</td> <td>lunr.SortedSet</td> <td><p>The set to union with this set.</p></td> </tr> </tbody> </table> <div class="description"><p>Creates a new lunr.SortedSet that contains the elements in the union<br />of this set and the passed set.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.union = function (otherSet) { var longSet, shortSet, unionSet if (this.length &gt;= otherSet.length) { longSet = this, shortSet = otherSet } else { longSet = otherSet, shortSet = this } unionSet = longSet.clone() for(var i = 0, shortSetElements = shortSet.toArray(); i &lt; shortSetElements.length; i++){ unionSet.add(shortSetElements[i]) } return unionSet }</code></pre> <section id="toJSON"> <h1>toJSON</h1> <h5 class="subheader"></h5> <p> <div class="label label-info radius ctx-type">method</div><span>lunr.SortedSet.prototype.toJSON()</span> </p> </section> <div class="description"><p>Returns a representation of the sorted set ready for serialisation.</p> </div> <pre><code class="language-javascript">lunr.SortedSet.prototype.toJSON = function () { return this.toArray() }</code></pre> </div> </div> </div> <footer class="footer"> <div class="container"> <p>Documentation generated with <a href="https://github.com/FGRibreau/doxx">Doxx </a> created by <a href="https://twitter.com/FGRibreau" data-show-count="false" class="twitter-follow-button">Francois-Guillaume Ribreau </a></p> <p>Doxx is sponsored by <a href="http://bringr.net/?btt" title="Outil d'analyse des réseaux sociaux" class="bringr">Bringr </a> and <a href="https://redsmin.com/?btt" title="Full Redis GUI" class="redsmin">Redsmin</a></p> <p>Theme borrowed from Twitter Bootstrap</p> </div> </footer> <script src="http://platform.twitter.com/widgets.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script src="http://leaverou.github.com/prefixfree/prefixfree.js"></script> <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-transition.js"></script> <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-scrollspy.js"></script> <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-dropdown.js"></script> <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-collapse.js"></script> <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-affix.js"></script> <script> /** * Prism: Lightweight, robust, elegant syntax highlighting * MIT license http://www.opensource.org/licenses/mit-license.php/ * @author Lea Verou http://lea.verou.me */(function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}},highlightAll:function(e,n){var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,s;s=r[i++];)t.highlightElement(s,e===!0,n)},highlightElement:function(r,i,s){var o,u,a=r;while(a&&!e.test(a.className))a=a.parentNode;if(a){o=(a.className.match(e)||[,""])[1];u=t.languages[o]}if(!u)return;r.className=r.className.replace(e,"").replace(/\s+/g," ")+" language-"+o;a=r.parentNode;/pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+o);var f=r.textContent;if(!f)return;f=f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\u00a0/g," ");var l={element:r,language:o,grammar:u,code:f};t.hooks.run("before-highlight",l);if(i&&self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){l.highlightedCode=n.stringify(JSON.parse(e.data));l.element.innerHTML=l.highlightedCode;s&&s.call(l.element);t.hooks.run("after-highlight",l)};c.postMessage(JSON.stringify({language:l.language,code:l.code}))}else{l.highlightedCode=t.highlight(l.code,l.grammar);l.element.innerHTML=l.highlightedCode;s&&s.call(r);t.hooks.run("after-highlight",l)}},highlight:function(e,r){return n.stringify(t.tokenize(e,r))},tokenize:function(e,n){var r=t.Token,i=[e],s=n.rest;if(s){for(var o in s)n[o]=s[o];delete n.rest}e:for(var o in n){if(!n.hasOwnProperty(o)||!n[o])continue;var u=n[o],a=u.inside,f=!!u.lookbehind||0;u=u.pattern||u;for(var l=0;l<i.length;l++){var c=i[l];if(i.length>e.length)break e;if(c instanceof r)continue;u.lastIndex=0;var h=u.exec(c);if(h){f&&(f=h[1].length);var p=h.index-1+f,h=h[0].slice(f),d=h.length,v=p+d,m=c.slice(0,p+1),g=c.slice(v+1),y=[l,1];m&&y.push(m);var b=new r(o,a?t.tokenize(h,a):h);y.push(b);g&&y.push(g);Array.prototype.splice.apply(i,y)}}}return i},hooks:{all:{},add:function(e,n){var r=t.hooks.all;r[e]=r[e]||[];r[e].push(n)},run:function(e,n){var r=t.hooks.all[e];if(!r||!r.length)return;for(var i=0,s;s=r[i++];)s(n)}}},n=t.Token=function(e,t){this.type=e;this.content=t};n.stringify=function(e){if(typeof e=="string")return e;if(Object.prototype.toString.call(e)=="[object Array]"){for(var r=0;r<e.length;r++)e[r]=n.stringify(e[r]);return e.join("")}var i={type:e.type,content:n.stringify(e.content),tag:"span",classes:["token",e.type],attributes:{}};i.type=="comment"&&(i.attributes.spellcheck="true");t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+"</"+i.tag+">"};if(!self.document){self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(t.tokenize(i,t.languages[r])));self.close()},!1);return}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){t.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)}})();; Prism.languages.markup={comment:/&lt;!--[\w\W]*?--(&gt;|&gt;)/g,prolog:/&lt;\?.+?\?&gt;/,doctype:/&lt;!DOCTYPE.+?&gt;/,cdata:/&lt;!\[CDATA\[[\w\W]+?]]&gt;/i,tag:{pattern:/&lt;\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?&gt;/gi,inside:{tag:{pattern:/^&lt;\/?[\w:-]+/i,inside:{punctuation:/^&lt;\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|&gt;|"/g}},punctuation:/\/?&gt;/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&amp;#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&amp;/,"&"))});; Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:/@[\w-]+?(\s+[^;{]+)?(?=\s*{|\s*;)/gi,url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\}]*(?=\s*\{)/g,property:/(\b|\B)[a-z-]+(?=\s*:)/ig,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/(&lt;|<)style[\w\W]*?(>|&gt;)[\w\W]*?(&lt;|<)\/style(>|&gt;)/ig,inside:{tag:{pattern:/(&lt;|<)style[\w\W]*?(>|&gt;)|(&lt;|<)\/style(>|&gt;)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}});; Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,number:/\b-?(0x)?\d*\.?[\da-f]+\b/g,operator:/[-+]{1,2}|!|=?&lt;|=?&gt;|={1,2}|(&amp;){1,2}|\|?\||\?|\*|\//g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};; Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,number:/\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/g});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}});Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(&lt;|<)script[\w\W]*?(>|&gt;)[\w\W]*?(&lt;|<)\/script(>|&gt;)/ig,inside:{tag:{pattern:/(&lt;|<)script[\w\W]*?(>|&gt;)|(&lt;|<)\/script(>|&gt;)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}});; </script> <!-- App js--> <script> $(function(){ var $window = $(window); $('.scrollspy .nav').affix({ offset: { top: function () { return $window.width() <= 980 ? 480 : 400 } , bottom: 50 } }); }) </script> </body> </html>