tubestats-presentation/dist/plugin/markdown.js

7 lines
32 KiB
JavaScript
Raw Normal View History

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).RevealMarkdown=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}var s=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){function t(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}}e.exports={defaults:{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1},getDefaults:t,changeDefaults:function(t){e.exports.defaults=t}}})),i=(s.defaults,s.getDefaults,s.changeDefaults,/[&<>"']/),a=/[&<>"']/g,l=/[<>"']|&(?!#?\w+;)/,o=/[<>"']|&(?!#?\w+;)/g,c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},u=function(e){return c[e]};var h=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function p(e){return e.replace(h,(function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""}))}var g=/(^|[^\[])\^/g;var f=/[^\w:]/g,d=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;var b={},k=/^[^:]+:\/*[^/]*$/,m=/^([^:]+:)[\s\S]*$/,x=/^([^:]+:\/*[^/]*)[\s\S]*$/;function y(e,t){b[" "+e]||(k.test(e)?b[" "+e]=e+"/":b[" "+e]=v(e,"/",!0));var n=-1===(e=b[" "+e]).indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(m,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(x,"$1")+t:e+t}function v(e,t,n){var r=e.length;if(0===r)return"";for(var s=0;s<r;){var i=e.charAt(r-s-1);if(i!==t||n){if(i===t||!n)break;s++}else s++}return e.substr(0,r-s)}var w=function(e,t){if(t){if(i.test(e))return e.replace(a,u)}else if(l.test(e))return e.replace(o,u);return e},_=p,S=function(e,t,n){if(e){var r;try{r=decodeURIComponent(p(n)).replace(f,"").toLowerCase()}catch(e){return null}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return null}t&&!d.test(n)&&(n=y(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n},A=function(e){for(var t,n,r=1;r<arguments.length;r++)for(n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},$=function(e,t){var n=e.replace(/\|/g,(function(e,t,n){for(var r=!1,s=t;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"})).split(/ \|/),r=0;if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n},R=v,z=function(e,t){if(-1===e.indexOf(t[1]))return-1;for(var n=e.length,r=0,s=0;s<n;s++)if("\\"===e[s])s++;else if(e[s]===t[0])r++;else if(e[s]===t[1]&&--r<0)return s;return-1},T=function(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")},E={exec:function(){}},L=function(e,t){e=e.source||e,t=t||"";var n={replace:function(t,r){return r=(r=r.source||r).replace(g,"$1"),e=e.replace(t,r),n},getRegex:function(){return new RegExp(e,t)}};return n},q=A,C={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(pa
/*!
* The reveal.js markdown plugin. Handles parsing of
* markdown inside of presentations as well as loading
* of external markdown documents.
*/return function(){var e;function t(e){var t=(e.querySelector("[data-template]")||e.querySelector("script")||e).textContent,n=(t=t.replace(new RegExp("__SCRIPT_END__","g"),"<\/script>")).match(/^\n?(\s*)/)[1].length,r=t.match(/^\n?(\t*)/)[1].length;return r>0?t=t.replace(new RegExp("\\n?\\t{"+r+"}","g"),"\n"):n>1&&(t=t.replace(new RegExp("\\n? {"+n+"}","g"),"\n")),t}function n(e){for(var t=e.attributes,n=[],r=0,s=t.length;r<s;r++){var i=t[r].name,a=t[r].value;/data\-(markdown|separator|vertical|notes)/gi.test(i)||(a?n.push(i+'="'+a+'"'):n.push(i))}return n.join(" ")}function r(e){return(e=e||{}).separator=e.separator||"^\r?\n---\r?\n$",e.notesSeparator=e.notesSeparator||"notes?:",e.attributes=e.attributes||"",e}function s(e,t){t=r(t);var n=e.split(new RegExp(t.notesSeparator,"mgi"));return 2===n.length&&(e=n[0]+'<aside class="notes">'+ae(n[1].trim())+"</aside>"),'<script type="text/template">'+(e=e.replace(/<\/script>/g,"__SCRIPT_END__"))+"<\/script>"}function i(e,t){t=r(t);for(var n,i,a,l=new RegExp(t.separator+(t.verticalSeparator?"|"+t.verticalSeparator:""),"mg"),o=new RegExp(t.separator),c=0,u=!0,h=[];n=l.exec(e);)!(i=o.test(n[0]))&&u&&h.push([]),a=e.substring(c,n.index),i&&u?h.push(a):h[h.length-1].push(a),c=l.lastIndex,u=i;(u?h:h[h.length-1]).push(e.substring(c));for(var p="",g=0,f=h.length;g<f;g++)h[g]instanceof Array?(p+="<section "+t.attributes+">",h[g].forEach((function(e){p+="<section data-markdown>"+s(e,t)+"</section>"})),p+="</section>"):p+="<section "+t.attributes+" data-markdown>"+s(h[g],t)+"</section>";return p}function a(e){return new Promise((function(r){var a=[];[].slice.call(e.querySelectorAll("[data-markdown]:not([data-markdown-parsed])")).forEach((function(e,r){e.getAttribute("data-markdown").length?a.push(function(e){return new Promise((function(t,n){var r=new XMLHttpRequest,s=e.getAttribute("data-markdown"),i=e.getAttribute("data-charset");null!=i&&""!=i&&r.overrideMimeType("text/html; charset="+i),r.onreadystatechange=function(e,r){4===r.readyState&&(r.status>=200&&r.status<300||0===r.status?t(r,s):n(r,s))}.bind(this,e,r),r.open("GET",s,!0);try{r.send()}catch(e){console.warn("Failed to get the Markdown file "+s+". Make sure that the presentation and the file are served by a HTTP server and the file can be found there. "+e),t(r,s)}}))}(e).then((function(t,r){e.outerHTML=i(t.responseText,{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})}),(function(t,n){e.outerHTML='<section data-state="alert">ERROR: The attempt to fetch '+n+" failed with HTTP status "+t.status+".Check your browser's JavaScript console for more details.<p>Remember that you need to serve the presentation HTML from a HTTP server.</p></section>"}))):e.getAttribute("data-separator")||e.getAttribute("data-separator-vertical")||e.getAttribute("data-separator-notes")?e.outerHTML=i(t(e),{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)}):e.innerHTML=s(t(e))})),Promise.all(a).then(r)}))}function l(e,t,n){var r,s,i=new RegExp(n,"mg"),a=new RegExp('([^"= ]+?)="([^"]+?)"|(data-[^"= ]+?)(?=[" ])',"mg"),l=e.nodeValue;if(r=i.exec(l)){var o=r[1];for(l=l.substring(0,r.index)+l.substring(i.lastIndex),e.nodeValue=l;s=a.exec(o);)s[2]?t.setAttribute(s[1],s[2]):t.setAttribute(s[3],"");return!0}return!1}function o(){var n=e.getRevealElement().querySelectorAll("[data-markdown]:not([data-markdown-parsed])");return[].slice.call(n).forEach((function(e){e.setAttribute("data-markdown-parsed",!0);var n=e.querySelector("aside.notes"),r=t(e);e.innerHTML=ae(r),function e(t,n,r,s,i){if(null!=n&&null!=n.childNodes&&n.childNodes.length>0)for(var a=n,o=0;o<n.childNodes.length;o++){var c=n.childNodes[o];if(o>0)for(var u=o-1;u>=0;){var h=n.childNodes[u];if("function"==typeof h.setAttribute&&"BR"!=h.tagName){a=h;break}u-=1}var p=t;"section"==c.nodeName&&(p=c,a=c),"function"!=typeof c.setAttribute&&c.nodeType!=Node.COMMEN