diff --git a/snippets/jsprettifier/README.md b/snippets/jsprettifier/README.md new file mode 100644 index 0000000..f6e2f66 --- /dev/null +++ b/snippets/jsprettifier/README.md @@ -0,0 +1,7 @@ +### jsprettifier + +Prettify JavaScript files directly in browser. + +[jsprettifier-bookmarklet](https://github.com/marcobarcelos/jsprettifier-bookmarklet) created by [Marco Barcelos](http://marcobarcelos.com). + +[![screenshot](jsprettifier.png)](jsprettifier.js) diff --git a/snippets/jsprettifier/jsprettifier.js b/snippets/jsprettifier/jsprettifier.js new file mode 100644 index 0000000..471ed55 --- /dev/null +++ b/snippets/jsprettifier/jsprettifier.js @@ -0,0 +1,41 @@ +// jsprettifier.js +// https://github.com/bgrins/devtools-snippets +// Prettify JavaScript files directly in browser. + +/** + * jsprettifier-bookmarklet + * A bookmarklet for prettifying JS directly in your browser + * https://github.com/marcobarcelos/jsprettifier-bookmarklet + * Copyright (c) 2015 Marco Barcelos + * Licensed under the MIT license + */ +(function () { + 'use strict'; + + function prettify() { + // JSBeautify (c) Einar Lielmanis and contributors, MIT License + (function(){function e(e,t){for(var n=0;nn&&(n=e.line_indent_level));var _={mode:t,parent:e,last_text:e?e.last_text:"",last_word:e?e.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,if_block:!1,else_block:!1,do_block:!1,do_while:!1,in_case_statement:!1,in_case:!1,case_body:!1,indentation_level:n,line_indent_level:e?e.line_indent_level:n,start_line_index:z.get_line_number(),ternary_depth:0};return _}function c(e){var t=e.newlines,n=te.keep_array_indentation&&K(q.mode);if(n)for(_=0;t>_;_+=1)u(_>0);else if(te.max_preserve_newlines&&t>te.max_preserve_newlines&&(t=te.max_preserve_newlines),te.preserve_newlines&&e.newlines>1){u();for(var _=1;t>_;_+=1)u(!0)}Q=e,ee[Q.type]()}function d(e){e=e.replace(/\x0d/g,"");for(var t=[],n=e.indexOf("\n");-1!==n;)t.push(e.substring(0,n)),e=e.substring(n+1),n=e.indexOf("\n");return e.length&&t.push(e),t}function f(e){if(e=void 0===e?!1:e,!z.just_added_newline())if(te.preserve_newlines&&Q.wanted_newline||e)u(!1,!0);else if(te.wrap_line_length){var t=z.current_line.get_character_count()+Q.text.length+(z.space_before_token?1:0);t>=te.wrap_line_length&&u(!1,!0)}}function u(e,t){if(!t&&";"!==q.last_text&&","!==q.last_text&&"="!==q.last_text&&"TK_OPERATOR"!==G)for(;q.mode===l.Statement&&!q.if_block&&!q.do_block;)m();z.add_new_line(e)&&(q.multiline_frame=!0)}function p(){z.just_added_newline()&&(te.keep_array_indentation&&K(q.mode)&&Q.wanted_newline?(z.current_line.push(Q.whitespace_before),z.space_before_token=!1):z.set_indent(q.indentation_level)&&(q.line_indent_level=q.indentation_level))}function h(e){return z.raw?void z.add_raw_token(Q):(te.comma_first&&"TK_COMMA"===G&&z.just_added_newline()&&","===z.previous_line.last()&&(z.previous_line.pop(),p(),z.add_token(","),z.space_before_token=!0),e=e||Q.text,p(),void z.add_token(e))}function E(){q.indentation_level+=1}function T(){q.indentation_level>0&&(!q.parent||q.indentation_level>q.parent.indentation_level)&&(q.indentation_level-=1)}function R(e){q?(J.push(q),H=q):H=i(null,e),q=i(H,e)}function K(e){return e===l.ArrayLiteral}function x(t){return e(t,[l.Expression,l.ForInitializer,l.Conditional])}function m(){J.length>0&&(H=q,q=J.pop(),H.mode===l.Statement&&z.remove_redundant_indentation(H))}function b(){return q.parent.mode===l.ObjectLiteral&&q.mode===l.Statement&&(":"===q.last_text&&0===q.ternary_depth||"TK_RESERVED"===G&&e(q.last_text,["get","set"]))}function v(){return"TK_RESERVED"===G&&e(q.last_text,["var","let","const"])&&"TK_WORD"===Q.type||"TK_RESERVED"===G&&"do"===q.last_text||"TK_RESERVED"===G&&"return"===q.last_text&&!Q.wanted_newline||"TK_RESERVED"===G&&"else"===q.last_text&&("TK_RESERVED"!==Q.type||"if"!==Q.text)||"TK_END_EXPR"===G&&(H.mode===l.ForInitializer||H.mode===l.Conditional)||"TK_WORD"===G&&q.mode===l.BlockStatement&&!q.in_case&&"--"!==Q.text&&"++"!==Q.text&&"function"!==$&&"TK_WORD"!==Q.type&&"TK_RESERVED"!==Q.type||q.mode===l.ObjectLiteral&&(":"===q.last_text&&0===q.ternary_depth||"TK_RESERVED"===G&&e(q.last_text,["get","set"]))?(R(l.Statement),E(),"TK_RESERVED"===G&&e(q.last_text,["var","let","const"])&&"TK_WORD"===Q.type&&(q.declaration_statement=!0),b()||f("TK_RESERVED"===Q.type&&e(Q.text,["do","for","if","while"])),!0):!1}function w(e,n){for(var _=0;__;_++)if(n=e[_],n&&0!==n.indexOf(t))return!1;return!0}function A(t){return e(t,["case","return","do","if","throw","else"])}function y(e){var t=F+(e||0);return 0>t||t>=ne.length?null:ne[t]}function O(){v();var t=l.Expression;if("["===Q.text){if("TK_WORD"===G||")"===q.last_text)return"TK_RESERVED"===G&&e(q.last_text,U.line_starters)&&(z.space_before_token=!0),R(t),h(),E(),void(te.space_in_paren&&(z.space_before_token=!0));t=l.ArrayLiteral,K(q.mode)&&("["===q.last_text||","===q.last_text&&("]"===$||"}"===$))&&(te.keep_array_indentation||u())}else"TK_RESERVED"===G&&"for"===q.last_text?t=l.ForInitializer:"TK_RESERVED"===G&&e(q.last_text,["if","while"])&&(t=l.Conditional);";"===q.last_text||"TK_START_BLOCK"===G?u():"TK_END_EXPR"===G||"TK_START_EXPR"===G||"TK_END_BLOCK"===G||"."===q.last_text?f(Q.wanted_newline):"TK_RESERVED"===G&&"("===Q.text||"TK_WORD"===G||"TK_OPERATOR"===G?"TK_RESERVED"===G&&("function"===q.last_word||"typeof"===q.last_word)||"*"===q.last_text&&"function"===$?te.space_after_anon_function&&(z.space_before_token=!0):"TK_RESERVED"!==G||!e(q.last_text,U.line_starters)&&"catch"!==q.last_text||te.space_before_conditional&&(z.space_before_token=!0):z.space_before_token=!0,"("===Q.text&&"TK_RESERVED"===G&&"await"===q.last_word&&(z.space_before_token=!0),"("===Q.text&&("TK_EQUALS"===G||"TK_OPERATOR"===G)&&(b()||f()),R(t),h(),te.space_in_paren&&(z.space_before_token=!0),E()}function g(){for(;q.mode===l.Statement;)m();q.multiline_frame&&f("]"===Q.text&&K(q.mode)&&!te.keep_array_indentation),te.space_in_paren&&("TK_START_EXPR"!==G||te.space_in_empty_paren?z.space_before_token=!0:(z.trim(),z.space_before_token=!1)),"]"===Q.text&&te.keep_array_indentation?(h(),m()):(m(),h()),z.remove_redundant_indentation(H),q.do_while&&H.mode===l.Conditional&&(H.mode=l.Expression,q.do_block=!1,q.do_while=!1)}function k(){var t=y(1),n=y(2);R(n&&(":"===n.text&&e(t.type,["TK_STRING","TK_WORD","TK_RESERVED"])||e(t.text,["get","set"])&&e(n.type,["TK_WORD","TK_RESERVED"]))?e($,["class","interface"])?l.BlockStatement:l.ObjectLiteral:l.BlockStatement);var _=!t.comments_before.length&&"}"===t.text,r=_&&"function"===q.last_word&&"TK_END_EXPR"===G;"expand"===te.brace_style||"none"===te.brace_style&&Q.wanted_newline?"TK_OPERATOR"!==G&&(r||"TK_EQUALS"===G||"TK_RESERVED"===G&&A(q.last_text)&&"else"!==q.last_text)?z.space_before_token=!0:u(!1,!0):"TK_OPERATOR"!==G&&"TK_START_EXPR"!==G?"TK_START_BLOCK"===G?u():z.space_before_token=!0:K(H.mode)&&","===q.last_text&&("}"===$?z.space_before_token=!0:u()),h(),E()}function D(){for(;q.mode===l.Statement;)m();var e="TK_START_BLOCK"===G;"expand"===te.brace_style?e||u():e||(K(q.mode)&&te.keep_array_indentation?(te.keep_array_indentation=!1,u(),te.keep_array_indentation=!0):u()),m(),h()}function C(){if("TK_RESERVED"===Q.type&&q.mode!==l.ObjectLiteral&&e(Q.text,["set","get"])&&(Q.type="TK_WORD"),"TK_RESERVED"===Q.type&&q.mode===l.ObjectLiteral){var t=y(1);":"==t.text&&(Q.type="TK_WORD")}if(v()||!Q.wanted_newline||x(q.mode)||"TK_OPERATOR"===G&&"--"!==q.last_text&&"++"!==q.last_text||"TK_EQUALS"===G||!te.preserve_newlines&&"TK_RESERVED"===G&&e(q.last_text,["var","let","const","set","get"])||u(),q.do_block&&!q.do_while){if("TK_RESERVED"===Q.type&&"while"===Q.text)return z.space_before_token=!0,h(),z.space_before_token=!0,void(q.do_while=!0);u(),q.do_block=!1}if(q.if_block)if(q.else_block||"TK_RESERVED"!==Q.type||"else"!==Q.text){for(;q.mode===l.Statement;)m();q.if_block=!1,q.else_block=!1}else q.else_block=!0;if("TK_RESERVED"===Q.type&&("case"===Q.text||"default"===Q.text&&q.in_case_statement))return u(),(q.case_body||te.jslint_happy)&&(T(),q.case_body=!1),h(),q.in_case=!0,void(q.in_case_statement=!0);if("TK_RESERVED"===Q.type&&"function"===Q.text&&((e(q.last_text,["}",";"])||z.just_added_newline()&&!e(q.last_text,["[","{",":","=",","]))&&(z.just_added_blankline()||Q.comments_before.length||(u(),u(!0))),"TK_RESERVED"===G||"TK_WORD"===G?"TK_RESERVED"===G&&e(q.last_text,["get","set","new","return","export","async"])?z.space_before_token=!0:"TK_RESERVED"===G&&"default"===q.last_text&&"export"===$?z.space_before_token=!0:u():"TK_OPERATOR"===G||"="===q.last_text?z.space_before_token=!0:(q.multiline_frame||!x(q.mode)&&!K(q.mode))&&u()),("TK_COMMA"===G||"TK_START_EXPR"===G||"TK_EQUALS"===G||"TK_OPERATOR"===G)&&(b()||f()),"TK_RESERVED"===Q.type&&e(Q.text,["function","get","set"]))return h(),void(q.last_word=Q.text);if(Y="NONE","TK_END_BLOCK"===G?"TK_RESERVED"===Q.type&&e(Q.text,["else","catch","finally"])?"expand"===te.brace_style||"end-expand"===te.brace_style||"none"===te.brace_style&&Q.wanted_newline?Y="NEWLINE":(Y="SPACE",z.space_before_token=!0):Y="NEWLINE":"TK_SEMICOLON"===G&&q.mode===l.BlockStatement?Y="NEWLINE":"TK_SEMICOLON"===G&&x(q.mode)?Y="SPACE":"TK_STRING"===G?Y="NEWLINE":"TK_RESERVED"===G||"TK_WORD"===G||"*"===q.last_text&&"function"===$?Y="SPACE":"TK_START_BLOCK"===G?Y="NEWLINE":"TK_END_EXPR"===G&&(z.space_before_token=!0,Y="NEWLINE"),"TK_RESERVED"===Q.type&&e(Q.text,U.line_starters)&&")"!==q.last_text&&(Y="else"===q.last_text||"export"===q.last_text?"SPACE":"NEWLINE"),"TK_RESERVED"===Q.type&&e(Q.text,["else","catch","finally"]))if("TK_END_BLOCK"!==G||"expand"===te.brace_style||"end-expand"===te.brace_style||"none"===te.brace_style&&Q.wanted_newline)u();else{z.trim(!0);var n=z.current_line;"}"!==n.last()&&u(),z.space_before_token=!0}else"NEWLINE"===Y?"TK_RESERVED"===G&&A(q.last_text)?z.space_before_token=!0:"TK_END_EXPR"!==G?"TK_START_EXPR"===G&&"TK_RESERVED"===Q.type&&e(Q.text,["var","let","const"])||":"===q.last_text||("TK_RESERVED"===Q.type&&"if"===Q.text&&"else"===q.last_text?z.space_before_token=!0:u()):"TK_RESERVED"===Q.type&&e(Q.text,U.line_starters)&&")"!==q.last_text&&u():q.multiline_frame&&K(q.mode)&&","===q.last_text&&"}"===$?u():"SPACE"===Y&&(z.space_before_token=!0);h(),q.last_word=Q.text,"TK_RESERVED"===Q.type&&"do"===Q.text&&(q.do_block=!0),"TK_RESERVED"===Q.type&&"if"===Q.text&&(q.if_block=!0)}function N(){for(v()&&(z.space_before_token=!1);q.mode===l.Statement&&!q.if_block&&!q.do_block;)m();h()}function L(){v()?z.space_before_token=!0:"TK_RESERVED"===G||"TK_WORD"===G?z.space_before_token=!0:"TK_COMMA"===G||"TK_START_EXPR"===G||"TK_EQUALS"===G||"TK_OPERATOR"===G?b()||f():u(),h()}function V(){v(),q.declaration_statement&&(q.declaration_assignment=!0),z.space_before_token=!0,h(),z.space_before_token=!0}function I(){return q.declaration_statement?(x(q.parent.mode)&&(q.declaration_assignment=!1),h(),void(q.declaration_assignment?(q.declaration_assignment=!1,u(!1,!0)):(z.space_before_token=!0,te.comma_first&&f()))):(h(),void(q.mode===l.ObjectLiteral||q.mode===l.Statement&&q.parent.mode===l.ObjectLiteral?(q.mode===l.Statement&&m(),u()):(z.space_before_token=!0,te.comma_first&&f())))}function P(){if(v(),"TK_RESERVED"===G&&A(q.last_text))return z.space_before_token=!0,void h();if("*"===Q.text&&"TK_DOT"===G)return void h();if(":"===Q.text&&q.in_case)return q.case_body=!0,E(),h(),u(),void(q.in_case=!1);if("::"===Q.text)return void h();"TK_OPERATOR"===G&&f();var t=!0,n=!0;e(Q.text,["--","++","!","~"])||e(Q.text,["-","+"])&&(e(G,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||e(q.last_text,U.line_starters)||","===q.last_text)?(t=!1,n=!1,!Q.wanted_newline||"--"!==Q.text&&"++"!==Q.text||u(!1,!0),";"===q.last_text&&x(q.mode)&&(t=!0),"TK_RESERVED"===G?t=!0:"TK_END_EXPR"===G?t=!("]"===q.last_text&&("--"===Q.text||"++"===Q.text)):"TK_OPERATOR"===G&&(t=e(Q.text,["--","-","++","+"])&&e(q.last_text,["--","-","++","+"]),e(Q.text,["+","-"])&&e(q.last_text,["--","++"])&&(n=!0)),q.mode!==l.BlockStatement&&q.mode!==l.Statement||"{"!==q.last_text&&";"!==q.last_text||u()):":"===Q.text?0===q.ternary_depth?t=!1:q.ternary_depth-=1:"?"===Q.text?q.ternary_depth+=1:"*"===Q.text&&"TK_RESERVED"===G&&"function"===q.last_text&&(t=!1,n=!1),z.space_before_token=z.space_before_token||t,h(),z.space_before_token=n}function M(){if(z.raw)return z.add_raw_token(Q),void(Q.directives&&"end"===Q.directives.preserve&&(te.test_output_raw||(z.raw=!1)));if(Q.directives)return u(!1,!0),h(),"start"===Q.directives.preserve&&(z.raw=!0),void u(!1,!0);if(!o.newline.test(Q.text)&&!Q.wanted_newline)return z.space_before_token=!0,h(),void(z.space_before_token=!0);var e,t=d(Q.text),_=!1,r=!1,i=Q.whitespace_before,a=i.length;for(u(!1,!0),t.length>1&&(w(t.slice(1),"*")?_=!0:S(t.slice(1),i)&&(r=!0)),h(t[0]),e=1;ea?h(t[e].substring(a)):z.add_token(t[e]);u(!1,!0)}function B(){Q.wanted_newline?u(!1,!0):z.trim(!0),z.space_before_token=!0,h(),u(!1,!0)}function j(){v(),"TK_RESERVED"===G&&A(q.last_text)?z.space_before_token=!0:f(")"===q.last_text&&te.break_chained_methods),h()}function W(){h(),"\n"===Q.text[Q.text.length-1]&&u()}function X(){for(;q.mode===l.Statement;)m()}var z,F,U,Q,G,$,Z,q,H,J,Y,ee,te,ne=[],_e="";for(ee={TK_START_EXPR:O,TK_END_EXPR:g,TK_START_BLOCK:k,TK_END_BLOCK:D,TK_WORD:C,TK_RESERVED:C,TK_SEMICOLON:N,TK_STRING:L,TK_EQUALS:V,TK_OPERATOR:P,TK_COMMA:I,TK_BLOCK_COMMENT:M,TK_COMMENT:B,TK_DOT:j,TK_UNKNOWN:W,TK_EOF:X},r=r?r:{},te={},void 0!==r.braces_on_own_line&&(te.brace_style=r.braces_on_own_line?"expand":"collapse"),te.brace_style=r.brace_style?r.brace_style:te.brace_style?te.brace_style:"collapse","expand-strict"===te.brace_style&&(te.brace_style="expand"),te.indent_size=r.indent_size?parseInt(r.indent_size,10):4,te.indent_char=r.indent_char?r.indent_char:" ",te.eol=r.eol?r.eol:"\n",te.preserve_newlines=void 0===r.preserve_newlines?!0:r.preserve_newlines,te.break_chained_methods=void 0===r.break_chained_methods?!1:r.break_chained_methods,te.max_preserve_newlines=void 0===r.max_preserve_newlines?0:parseInt(r.max_preserve_newlines,10),te.space_in_paren=void 0===r.space_in_paren?!1:r.space_in_paren,te.space_in_empty_paren=void 0===r.space_in_empty_paren?!1:r.space_in_empty_paren,te.jslint_happy=void 0===r.jslint_happy?!1:r.jslint_happy,te.space_after_anon_function=void 0===r.space_after_anon_function?!1:r.space_after_anon_function,te.keep_array_indentation=void 0===r.keep_array_indentation?!1:r.keep_array_indentation,te.space_before_conditional=void 0===r.space_before_conditional?!0:r.space_before_conditional,te.unescape_strings=void 0===r.unescape_strings?!1:r.unescape_strings,te.wrap_line_length=void 0===r.wrap_line_length?0:parseInt(r.wrap_line_length,10),te.e4x=void 0===r.e4x?!1:r.e4x,te.end_with_newline=void 0===r.end_with_newline?!1:r.end_with_newline,te.comma_first=void 0===r.comma_first?!1:r.comma_first,te.test_output_raw=void 0===r.test_output_raw?!1:r.test_output_raw,te.jslint_happy&&(te.space_after_anon_function=!0),r.indent_with_tabs&&(te.indent_char=" ",te.indent_size=1),te.eol=te.eol.replace(/\\r/,"\r").replace(/\\n/,"\n"),Z="";te.indent_size>0;)Z+=te.indent_char,te.indent_size-=1;var re=0;if(_&&_.length){for(;" "===_.charAt(re)||" "===_.charAt(re);)_e+=_.charAt(re),re+=1;_=_.substring(re)}G="TK_START_BLOCK",$="",z=new a(Z,_e),z.raw=te.test_output_raw,J=[],R(l.BlockStatement),this.beautify=function(){var e,t;for(U=new s(_,te,Z),ne=U.tokenize(),F=0;e=y();){for(var n=0;n0&&(n-=1,t-=e.indent_length)},this.trim=function(){for(;" "===this.last();){_.pop();t-=1}r=0===_.length},this.toString=function(){var t="";return this._empty||(n>=0&&(t=e.indent_cache[n]),t+=_.join("")),t}}function a(e,t){t=t||"",this.indent_cache=[t],this.baseIndentLength=t.length,this.indent_length=e.length,this.raw=!1;var n=[];this.baseIndentString=t,this.indent_string=e,this.previous_line=null,this.current_line=null,this.space_before_token=!1,this.add_outputline=function(){this.previous_line=this.current_line,this.current_line=new i(this),n.push(this.current_line)},this.add_outputline(),this.get_line_number=function(){return n.length},this.add_new_line=function(e){return 1===this.get_line_number()&&this.just_added_newline()?!1:e||!this.just_added_newline()?(this.raw||this.add_outputline(),!0):!1},this.get_code=function(){var e=n.join("\n").replace(/[\r\n\t ]+$/,"");return e},this.set_indent=function(e){if(n.length>1){for(;e>=this.indent_cache.length;)this.indent_cache.push(this.indent_cache[this.indent_cache.length-1]+this.indent_string);return this.current_line.set_indent(e),!0}return this.current_line.set_indent(0),!1},this.add_raw_token=function(e){for(var t=0;tt;)n[t].remove_indent(),t++},this.trim=function(_){for(_=void 0===_?!1:_,this.current_line.trim(e,t);_&&n.length>1&&this.current_line.is_empty();)n.pop(),this.current_line=n[n.length-1],this.current_line.trim();this.previous_line=n.length>1?n[n.length-2]:null},this.just_added_newline=function(){return this.current_line.is_empty()},this.just_added_blankline=function(){if(this.just_added_newline()){if(1===n.length)return!0;var e=n[n.length-2];return e.is_empty()}return!1}}function s(n,_,r){function i(e){if(!e.match(v))return null;var t={};w.lastIndex=0;for(var n=w.exec(e);n;)t[n[1]]=n[2],n=w.exec(e);return t}function a(){var r,a=[];if(p=0,h="",R>=K)return["","TK_EOF"];var v;v=T.length?T[T.length-1]:new c("TK_START_BLOCK","{");var w=n.charAt(R);for(R+=1;e(w,l);){if(o.newline.test(w)?("\n"!==w||"\r"!==n.charAt(R-2))&&(p+=1,a=[]):a.push(w),R>=K)return["","TK_EOF"];w=n.charAt(R),R+=1}if(a.length&&(h=a.join("")),d.test(w)){var y=!0,O=!0,g=d;for("0"===w&&K>R&&/[Xx]/.test(n.charAt(R))?(y=!1,O=!1,w+=n.charAt(R),R+=1,g=f):(w="",R-=1);K>R&&g.test(n.charAt(R));)w+=n.charAt(R),R+=1,y&&K>R&&"."===n.charAt(R)&&(w+=n.charAt(R),R+=1,y=!1),O&&K>R&&/[Ee]/.test(n.charAt(R))&&(w+=n.charAt(R),R+=1,K>R&&/[+-]/.test(n.charAt(R))&&(w+=n.charAt(R),R+=1),O=!1,y=!1);return[w,"TK_WORD"]}if(o.isIdentifierStart(n.charCodeAt(R-1))){if(K>R)for(;o.isIdentifierChar(n.charCodeAt(R))&&(w+=n.charAt(R),R+=1,R!==K););return"TK_DOT"===v.type||"TK_RESERVED"===v.type&&e(v.text,["set","get"])||!e(w,x)?[w,"TK_WORD"]:"in"===w?[w,"TK_OPERATOR"]:[w,"TK_RESERVED"]}if("("===w||"["===w)return[w,"TK_START_EXPR"];if(")"===w||"]"===w)return[w,"TK_END_EXPR"];if("{"===w)return[w,"TK_START_BLOCK"];if("}"===w)return[w,"TK_END_BLOCK"];if(";"===w)return[w,"TK_SEMICOLON"];if("/"===w){var k="";if("*"===n.charAt(R)){R+=1,m.lastIndex=R;var D=m.exec(n);k="/*"+D[0],R+=D[0].length;var C=i(k);return C&&"start"===C.ignore&&(S.lastIndex=R,D=S.exec(n),k+=D[0],R+=D[0].length),k=k.replace(o.lineBreak,"\n"),[k,"TK_BLOCK_COMMENT",C]}if("/"===n.charAt(R)){R+=1,b.lastIndex=R;var D=b.exec(n);return k="//"+D[0],R+=D[0].length,[k,"TK_COMMENT"]}}if("`"===w||"'"===w||'"'===w||("/"===w||_.e4x&&"<"===w&&n.slice(R-1).match(/^<([-a-zA-Z:0-9_.]+|{[^{}]*}|!\[CDATA\[[\s\S]*?\]\])(\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{.*?}))*\s*(\/?)\s*>/))&&("TK_RESERVED"===v.type&&e(v.text,["return","case","throw","else","do","typeof","yield"])||"TK_END_EXPR"===v.type&&")"===v.text&&v.parent&&"TK_RESERVED"===v.parent.type&&e(v.parent.text,["if","while","for"])||e(v.type,["TK_COMMENT","TK_START_EXPR","TK_START_BLOCK","TK_END_BLOCK","TK_OPERATOR","TK_EQUALS","TK_EOF","TK_SEMICOLON","TK_COMMA"]))){var N=w,L=!1,V=!1;if(r=w,"/"===N)for(var I=!1;K>R&&(L||I||n.charAt(R)!==N)&&!o.newline.test(n.charAt(R));)r+=n.charAt(R),L?L=!1:(L="\\"===n.charAt(R),"["===n.charAt(R)?I=!0:"]"===n.charAt(R)&&(I=!1)),R+=1;else if(_.e4x&&"<"===N){var P=/<(\/?)([-a-zA-Z:0-9_.]+|{[^{}]*}|!\[CDATA\[[\s\S]*?\]\])(\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{.*?}))*\s*(\/?)\s*>/g,M=n.slice(R-1),B=P.exec(M);if(B&&0===B.index){for(var j=B[2],W=0;B;){var X=!!B[1],z=B[2],F=!!B[B.length-1]||"![CDATA["===z.slice(0,8);if(z!==j||F||(X?--W:++W),0>=W)break;B=P.exec(M)}var U=B?B.index+B[0].length:M.length;return M=M.slice(0,U),R+=U-1,M=M.replace(o.lineBreak,"\n"),[M,"TK_STRING"]}}else for(;K>R&&(L||n.charAt(R)!==N&&("`"===N||!o.newline.test(n.charAt(R))));)(L||"`"===N)&&o.newline.test(n.charAt(R))?("\r"===n.charAt(R)&&"\n"===n.charAt(R+1)&&(R+=1),r+="\n"):r+=n.charAt(R),L?(("x"===n.charAt(R)||"u"===n.charAt(R))&&(V=!0),L=!1):L="\\"===n.charAt(R),R+=1;if(V&&_.unescape_strings&&(r=s(r)),K>R&&n.charAt(R)===N&&(r+=N,R+=1,"/"===N))for(;K>R&&o.isIdentifierStart(n.charCodeAt(R));)r+=n.charAt(R),R+=1;return[r,"TK_STRING"]}if("#"===w){if(0===T.length&&"!"===n.charAt(R)){for(r=w;K>R&&"\n"!==w;)w=n.charAt(R),r+=w,R+=1;return[t(r)+"\n","TK_UNKNOWN"]}var Q="#";if(K>R&&d.test(n.charAt(R))){do w=n.charAt(R),Q+=w,R+=1;while(K>R&&"#"!==w&&"="!==w);return"#"===w||("["===n.charAt(R)&&"]"===n.charAt(R+1)?(Q+="[]",R+=2):"{"===n.charAt(R)&&"}"===n.charAt(R+1)&&(Q+="{}",R+=2)),[Q,"TK_WORD"]}}if("<"===w&&("?"===n.charAt(R)||"%"===n.charAt(R))){A.lastIndex=R-1;var G=A.exec(n);if(G)return w=G[0],R+=w.length-1,w=w.replace(o.lineBreak,"\n"),[w,"TK_STRING"]}if("<"===w&&""===n.substring(R-1,R+2))return E=!1,R+=2,["-->","TK_COMMENT"];if("."===w)return[w,"TK_DOT"];if(e(w,u)){for(;K>R&&e(w+n.charAt(R),u)&&(w+=n.charAt(R),R+=1,!(R>=K)););return","===w?[w,"TK_COMMA"]:"="===w?[w,"TK_EQUALS"]:[w,"TK_OPERATOR"]}return[w,"TK_UNKNOWN"]}function s(e){for(var t,n=!1,_="",r=0,i="",a=0;n||r=0&&32>a){_+="x"===t?"\\x"+i:"\\u"+i;continue}if(34===a||39===a||92===a)_+="\\"+String.fromCharCode(a);else{if("x"===t&&a>126&&255>=a)return e;_+=String.fromCharCode(a)}}else"\\"===t?n=!0:_+=t;return _}var l="\n\r ".split(""),d=/[0-9]/,f=/[0123456789abcdefABCDEF]/,u="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! ~ , : ? ^ ^= |= :: =>".split(" ");this.line_starters="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",");var p,h,E,T,R,K,x=this.line_starters.concat(["do","in","else","get","set","new","catch","finally","typeof","yield","async","await"]),m=/([\s\S]*?)((?:\*\/)|$)/g,b=/([^\n\r\u2028\u2029]*)/g,v=/\/\* beautify( \w+[:]\w+)+ \*\//g,w=/ (\w+)[:](\w+)/g,S=/([\s\S]*?)((?:\/\*\sbeautify\signore:end\s\*\/)|$)/g,A=/((<\?php|<\?=)[\s\S]*?\?>)|(<%[\s\S]*?%>)/g;this.tokenize=function(){K=n.length,R=0,E=!1,T=[];for(var e,t,_,r=null,i=[],s=[];!t||"TK_EOF"!==t.type;){for(_=a(),e=new c(_[1],_[0],p,h);"TK_COMMENT"===e.type||"TK_BLOCK_COMMENT"===e.type||"TK_UNKNOWN"===e.type;)"TK_BLOCK_COMMENT"===e.type&&(e.directives=_[2]),s.push(e),_=a(),e=new c(_[1],_[0],p,h);s.length&&(e.comments_before=s,s=[]),"TK_START_BLOCK"===e.type||"TK_START_EXPR"===e.type?(e.parent=t,i.push(r),r=e):("TK_END_BLOCK"===e.type||"TK_END_EXPR"===e.type)&&r&&("]"===e.text&&"["===r.text||")"===e.text&&"("===r.text||"}"===e.text&&"{"===r.text)&&(e.parent=r.parent,r=i.pop()),T.push(e),t=e}return T}}var o={};(function(e){var t="\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc",n="\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f",_=new RegExp("["+t+"]"),r=new RegExp("["+t+n+"]");e.newline=/[\n\r\u2028\u2029]/,e.lineBreak=/\r\n|[\n\r\u2028\u2029]/g,e.isIdentifierStart=function(e){return 65>e?36===e:91>e?!0:97>e?95===e:123>e?!0:e>=170&&_.test(String.fromCharCode(e))},e.isIdentifierChar=function(e){return 48>e?36===e:58>e?!0:65>e?!1:91>e?!0:97>e?95===e:123>e?!0:e>=170&&r.test(String.fromCharCode(e))}})(o);var l={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"},c=function(e,t,n,_,r,i){this.type=e,this.text=t,this.comments_before=[],this.newlines=n||0,this.wanted_newline=n>0,this.whitespace_before=_||"",this.parent=null,this.directives=null};"function"==typeof define&&define.amd?define([],function(){return{js_beautify:_}}):"undefined"!=typeof exports?exports.js_beautify=_:"undefined"!=typeof window?window.js_beautify=_:"undefined"!=typeof global&&(global.js_beautify=_)})(); + + // Prism (c) Lea Verou, MIT License + (function(){var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),P=[p,1];b&&P.push(b);var A=new a(i,g?t.tokenize(m,g):m,h);P.push(A),w&&P.push(w),Array.prototype.splice.apply(r,P)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,l=0;r=a[l++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var l={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==l.type&&(l.attributes.spellcheck="true"),e.alias){var i="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}t.hooks.run("wrap",l);var o="";for(var s in l.attributes)o+=(o?" ":"")+s+'="'+(l.attributes[s]||"")+'"';return"<"+l.tag+' class="'+l.classes.join(" ")+'" '+o+">"+l.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code,l=n.immediateClose;_self.postMessage(t.highlight(r,t.languages[a],a)),l&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);})(); + Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; + Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}),Prism.languages.js=Prism.languages.javascript; + + // Set style + var style = document.createElement('style'); + style.textContent = 'body,html{padding:0;margin:0;}code[class*=language-],pre[class*=language-]{color:#333;font-size: 13.5px;font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;-moz-tab-size:4;-o-tab-size:4;line-height:1.45;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:.5em .75em;margin:0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#333}.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#3554FF}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#395CC7}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#BD0054;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#D63680}.token.function{color:#8054C3}.token.important,.token.regex,.token.variable{color:#0B9BCC}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}'; + document.head.innerHTML = ''; + document.head.appendChild(style); + + // Fill body + var textContent = document.body.textContent; + var beautified = js_beautify(textContent, { end_with_newline: true, indent_size: 2 }); + var highlighted = Prism.highlight(beautified, Prism.languages.javascript); + document.body.innerHTML = '
' + highlighted + '
'; + } + + // Loading state + document.body.innerHTML = '
' + document.body.innerHTML + '
'; + setTimeout(prettify, 50); + +})(); \ No newline at end of file diff --git a/snippets/jsprettifier/jsprettifier.png b/snippets/jsprettifier/jsprettifier.png new file mode 100644 index 0000000..a499476 Binary files /dev/null and b/snippets/jsprettifier/jsprettifier.png differ