theread.me/js/auto-render.min.js

2 lines
10 KiB
JavaScript
Raw Normal View History

2017-09-29 19:32:26 +00:00
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.renderMathInElement=e()}})(function(){var e,t,n;return function e(t,n,r){function o(c,a){if(!n[c]){if(!t[c]){var u=typeof require=="function"&&require;if(!a&&u)return u(c,!0);if(i)return i(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[c]={exports:{}};t[c][0].call(s.exports,function(e){var n=t[c][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[c].exports}var i=typeof require=="function"&&require;for(var c=0;c<r.length;c++)o(r[c]);return o}({1:[function(e,t,n){"use strict";var r=e("babel-runtime/core-js/object/assign");var o=i(r);function i(e){return e&&e.__esModule?e:{default:e}}var c=e("./splitAtDelimiters");var a=function e(t,n){var r=[{type:"text",data:t}];for(var o=0;o<n.length;o++){var i=n[o];r=c(r,i.left,i.right,i.display||false)}return r};var u=function e(t,n){var r=a(t,n.delimiters);var o=document.createDocumentFragment();for(var i=0;i<r.length;i++){if(r[i].type==="text"){o.appendChild(document.createTextNode(r[i].data))}else{var c=document.createElement("span");var u=r[i].data;n.displayMode=r[i].display;try{katex.render(u,c,n)}catch(e){if(!(e instanceof katex.ParseError)){throw e}n.errorCallback("KaTeX auto-render: Failed to parse `"+r[i].data+"` with ",e);o.appendChild(document.createTextNode(r[i].rawData));continue}o.appendChild(c)}}return o};var f=function e(t,n){for(var r=0;r<t.childNodes.length;r++){var o=t.childNodes[r];if(o.nodeType===3){var i=u(o.textContent,n);r+=i.childNodes.length-1;t.replaceChild(i,o)}else if(o.nodeType===1){var c=n.ignoredTags.indexOf(o.nodeName.toLowerCase())===-1;if(c){e(o,n)}}}};var s={delimiters:[{left:"$$",right:"$$",display:true},{left:"\\[",right:"\\]",display:true},{left:"\\(",right:"\\)",display:false}],ignoredTags:["script","noscript","style","textarea","pre","code"],errorCallback:function e(t,n){console.error(t,n)}};var l=function e(t,n){if(!t){throw new Error("No element provided to render")}var r=(0,o.default)({},s,n);f(t,r)};t.exports=l},{"./splitAtDelimiters":2,"babel-runtime/core-js/object/assign":3}],2:[function(e,t,n){"use strict";var r=function e(t,n,r){var o=r;var i=0;var c=t.length;while(o<n.length){var a=n[o];if(i<=0&&n.slice(o,o+c)===t){return o}else if(a==="\\"){o++}else if(a==="{"){i++}else if(a==="}"){i--}o++}return-1};var o=function e(t,n,o,i){var c=[];for(var a=0;a<t.length;a++){if(t[a].type==="text"){var u=t[a].data;var f=true;var s=0;var l=void 0;l=u.indexOf(n);if(l!==-1){s=l;c.push({type:"text",data:u.slice(0,s)});f=false}while(true){if(f){l=u.indexOf(n,s);if(l===-1){break}c.push({type:"text",data:u.slice(s,l)});s=l}else{l=r(o,u,s+n.length);if(l===-1){break}c.push({type:"math",data:u.slice(s+n.length,l),rawData:u.slice(s,l+o.length),display:i});s=l+o.length}f=!f}c.push({type:"text",data:u.slice(s)})}else{c.push(t[a])}}return c};t.exports=o},{}],3:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/assign"),__esModule:true}},{"core-js/library/fn/object/assign":4}],4:[function(e,t,n){e("../../modules/es6.object.assign");t.exports=e("../../modules/_core").Object.assign},{"../../modules/_core":9,"../../modules/es6.object.assign":39}],5:[function(e,t,n){t.exports=function(e){if(typeof e!="function")throw TypeError(e+" is not a function!");return e}},{}],6:[function(e,t,n){var r=e("./_is-object");t.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},{"./_is-object":22}],7:[function(e,t,n){var r=e("./_to-iobject"),o=e("./_to-length"),i=e("./_to-index");t.exports=function(e){return function(t,n,c){var a=r(t),u=o(a.length),f=i(c,u),s;if(e&&n!=n)while(u>f){s=a[f++];if(s!=s)return true}else for(;u>f;f++)if(e||f in a){if(a[f]===n)return e||f||0}return!e&&-1}}},{"./_to-index":32,"./_to-iobject":34,"./_to-length":35}],8:[function(e,t,n){var r={}.toString;t.exports=function(