docsify-glossary.min.js 3.9 KB

12345678
  1. /*!
  2. * @stijn-dejongh/docsify-glossary
  3. * v1.0.0
  4. * https://github.com/stijn-dejongh/docsify-glossary#readme
  5. * (c) 2018-2022 Stijn Dejongh
  6. * Apache-2.0 license
  7. */
  8. this["@stijn-dejongh/docsify-glossary"]=this["@stijn-dejongh/docsify-glossary"]||{},this["@stijn-dejongh/docsify-glossary"].js=function(e){"use strict";function t(e){return e.trim().startsWith("#")}function n(e,n,o,i){var r="",c=!1;return e.split("\n").forEach((function(e,s){e.trim().startsWith("```")&&(c=!c);var a=e;e.trim().length>0&&!c&&(a=function(e,n,o,i){if(t(n)&&!i.replaceTitleTerms)return n;var r=new RegExp("\\s(".concat(e,")[\\s$]"),"ig"),c=new RegExp("\\s(".concat(e,"),"),"ig"),s=new RegExp("\\s(".concat(e,")\\."),"ig"),a=" [$1](/".concat(i.glossaryLocation.replace(".md",""),"?id=").concat(o,")"),l=n.replace(c,a+",").replace(r,a+" ").replace(s,a+".");return t(n)?l.replaceAll("[".concat(e,"]"),"[ ".concat(e,"]")):l}(n,e+" ",o,i).trimEnd()),r+=a+"\n"})),r}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c="#####",s="_glossary.md",a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r(this,"terminologyHeading",""),r(this,"glossaryLocation",""),r(this,"debug",!1),r(this,"replaceTitleTerms",!0),this.terminologyHeading=c,this.glossaryLocation=s}var t,n,a;return t=e,n=[{key:"withTermHeading",value:function(e){return this.terminologyHeading=e,this}},{key:"withGlossaryLocation",value:function(e){return this.glossaryLocation=e,this}},{key:"withDebugEnabled",value:function(e){return this.debug=e,this}},{key:"withTitleTermReplacement",value:function(e){return this.replaceTitleTerms=e,this}},{key:"build",value:function(){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},this)}}],n&&i(t.prototype,n),a&&i(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();function l(e,t,o){o(e=function(e,t,o){var i=e;for(var r in o.debug&&console.log("Adding links for terminology: ".concat(t)),t)i=n(i,r,t[r],o);return i}(e,window.$docsify.terms,t))}function u(){if(void 0!==window.$docsify&&void 0!==window.$docsify.glossify){var e=window.$docsify.glossify;return t=e,(new a).withTermHeading(null!==(n=t.terminologyHeading)&&void 0!==n?n:c).withGlossaryLocation(null!==(o=t.glossaryLocation)&&void 0!==o?o:s).withDebugEnabled(null!==(i=t.debug)&&void 0!==i&&i).withTitleTermReplacement(null===(r=t.replaceTitleTerms)||void 0===r||r).build()}return(new a).build();var t,n,o,i,r}function f(e,t){var n=u();n.debug&&console.log("Using config options: ".concat(n.glossaryLocation,", ").concat(n.terminologyHeading)),e.beforeEach((function(e,t){window.location.hash.match(/_glossary/g)?t(e):(window.$docsify.terms||fetch(n.glossaryLocation).then((function(o){o.text().then((function(o){window.$docsify.terms=function(e,t){var n=e.split("\n"),o={};return n.forEach((function(e){if(e.trimStart().startsWith(t.terminologyHeading)){var n=e.replace(t.terminologyHeading,"").trim();t.debug&&console.log("detected glossary term: ".concat(n)),o[n]=n.toLowerCase().replace(" ","-")}})),o}(o,n),l(e,n,t)}))})),l(e,n,t))}))}return window.$docsify||(window.$docsify={}),window.$docsify.plugins=(window.$docsify.plugins||[]).concat(f),e.install=f,Object.defineProperty(e,"__esModule",{value:!0}),e}({});