simple-syntax-highlighter
Advanced tools
Comparing version 1.4.9 to 1.4.10
@@ -1,1 +0,1 @@ | ||
"use strict";const t={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,htmlTag:/(<([^>])*>)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},e={shell:{quote:t.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z\-:]+)([\s\S]*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-z]\w*)([\s\S]*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text2:/((?:^|\n)[ \t]+|^)\|([ \t]*)([^\n]+(?=\n|$))/,quote:t.quote,comment:/(?:^|\n)([ \t]+|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\1[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(([\s\S]*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:t.quote,comment:/(\/\*[\s\S]*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:t.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:t.quote,comment:t.comment,number:t.number,boolean:t.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:t.quote,comment:t.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:t.quote,comment:t.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:t.punctuation,number:t.number,boolean:t.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:t.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,punctuation:t.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},n={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')([\s\S]*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')([\s\S]*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g},a={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{quote:2,comment:2,text:4,text2:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},s={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(e),content:"",slotTexts:""}),methods:{htmlize:t=>t.replace(/&(lt|gt|amp);/g,((t,e)=>({lt:"<",gt:">",amp:"&"}[e]))),unhtmlize:t=>t.replace(/[<>]/g,(t=>({"<":"<",">":">"}[t]))),isColorDark(t){let e,n,a,s,o,i;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))a=parseInt(e[1])<=100,s=parseInt(e[2])<=100,o=parseInt(e[3])<=100,i=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const t=3===n[1].length;a=parseInt(n[1][0])<=9,s=parseInt(n[1][t?1:2])<=9,o=parseInt(n[1][t?2:4])<=9}return(a&&s&&o||a&&s&&!o||!a&&s&&o)&&!i},createRegexPattern(){let t="";const n=[];for(const s in e[this.language]){const o=a[this.language][s]||1;for(let t=0;t<o;t++)n.push(s);t+=(t?"|":"")+e[this.language][s].source}return[t,n]},syntaxHighlightHtmlTag(t){let e=(t[2]||"").replace(n[this.language],((t,e,n,a,s)=>`${e}<span class="attribute">${n}</span>`+(s?'<span class="punctuation">=</span>':"")+(s?`<span class="quote">${a||""}${s||""}${a||""}</span>`:"")));if("pug"===this.language){const n=(t[1]||"").replace(/\.[a-z\d-]+/g,(t=>`<span class="class">${t}</span>`));return e&&(e='<span class="punctuation">(</span>'+e+'<span class="punctuation">)</span>'),`<span class="tag-name">${t[0]||""}</span>${n}${e}`+(t[3]?'<span class="punctuation">.</span>':"")+(t[4]||"")+`${t[5]?t[5]:""}`}return`<span class="punctuation">${t[0]}</span><span class="tag-name">${t[1]}</span>`+e+`<span class="punctuation">${t[3]}</span>`},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t).replace(new RegExp(e,"g"),((t,...e)=>{let a,s=(e=e.slice(0,e.length-2)).find(((t,e)=>t&&(a=n[e])&&t));if("quote"===a)s=this.unhtmlize(s);else if("comment"===a)s=this.unhtmlize(s);else{if("text"===a&&"pug"===this.language)return`${e[0]}${e[1]}${e[2]}<span class="punctuation">.</span>\n<span class="text">${e[3]}</span>`;if("text2"===a&&"pug"===this.language)return`${e[0]}<span class="punctuation">|</span>${e[1]}<span class="text">${e[2]}</span>`;if("tag"===a&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(e.slice(n.indexOf("tag")));if("variable"===a&&"."===s[0]&&"js"===this.language)return`<span class="punctuation">.</span><span class="obj-attr">${s.substr(1)}</span>`}let o="";return"color"===a&&"css"===this.language&&(o=` style="background-color: ${s};color: #${this.isColorDark(s)?"fff":"000"}"`),a&&`<span class="${a}"${o}>${s}</span>`||""}))},checkSlots(){const t=(this.$slots.default||[]).map((t=>t.text||"")).join("");this.slotTexts!==t&&(this.slotTexts=t,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()},beforeUpdate(){this.reactive&&this.checkSlots()}},o={};var i=function(t,e,n,a,s,o,i,r){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),i?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(t,e){return l.call(e),u(t,e)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:t,options:c}}(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"ssh-pre",class:{"ssh-pre--dark":t.dark},attrs:{"data-type":t.language,"data-label":t.label||null}},[t.copyButton?n("button",{staticClass:"ssh-pre__copy",on:{click:t.copyCode}},[t._t("copy-button",(function(){return[t._v("Copy")]}))],2):t._e(),t._v(" "),n("pre",{ref:"code",staticClass:"ssh-pre__content",domProps:{innerHTML:t._s(t.content)}})])}),[],!1,(function(t){for(let e in o)this[e]=o[e]}),null,null,null);i.options.__file="src/components/simple-syntax-highlighter.vue";var r=i.exports;module.exports=r; | ||
"use strict";const t={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,htmlTag:/(<([^>])*>)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},e={shell:{quote:t.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z\-:]+)([\s\S]*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-z]\w*)([\s\S]*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\n|$))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\1[ \t]+)|(?=\1[ \t]+)[\s\S]+?(?:\n|$)*?)*)(?=\n|$)/,quote:t.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\1[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(([\s\S]*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:t.quote,comment:/(\/\*[\s\S]*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:t.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:t.quote,comment:t.comment,number:t.number,boolean:t.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:t.quote,comment:t.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:t.quote,comment:t.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:t.punctuation,number:t.number,boolean:t.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:t.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,punctuation:t.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},n={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')([\s\S]*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')([\s\S]*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g},a={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},s={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(e),content:"",slotTexts:""}),methods:{htmlize:t=>t.replace(/&(lt|gt|amp);/g,((t,e)=>({lt:"<",gt:">",amp:"&"}[e]))),unhtmlize:t=>t.replace(/[<>]/g,(t=>({"<":"<",">":">"}[t]))),isColorDark(t){let e,n,a,s,o,i;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))a=parseInt(e[1])<=100,s=parseInt(e[2])<=100,o=parseInt(e[3])<=100,i=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const t=3===n[1].length;a=parseInt(n[1][0])<=9,s=parseInt(n[1][t?1:2])<=9,o=parseInt(n[1][t?2:4])<=9}return(a&&s&&o||a&&s&&!o||!a&&s&&o)&&!i},createRegexPattern(){let t="";const n=[];for(const s in e[this.language]){const o=a[this.language][s]||1;for(let t=0;t<o;t++)n.push(s);t+=(t?"|":"")+e[this.language][s].source}return[t,n]},syntaxHighlightHtmlTag(t){let e=(t[2]||"").replace(n[this.language],((t,e,n,a,s)=>`${e}<span class="attribute">${n}</span>`+(s?'<span class="punctuation">=</span>':"")+(s?`<span class="quote">${a||""}${s||""}${a||""}</span>`:"")));if("pug"===this.language){const n=(t[1]||"").replace(/#[a-z\d-]+/g,(t=>`<span class="id">${t}</span>`)).replace(/\.[a-z\d-]+/g,(t=>`<span class="class">${t}</span>`));return e&&(e='<span class="punctuation">(</span>'+e+'<span class="punctuation">)</span>'),`<span class="tag-name">${t[0]||""}</span>${n}${e}`+(t[3]?'<span class="punctuation">.</span>':"")+(t[4]||"")+(t[5]?`<span class="text">${t[5]}</span>`:"")}return`<span class="punctuation">${t[0]}</span><span class="tag-name">${t[1]}</span>`+e+`<span class="punctuation">${t[3]}</span>`},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t).replace(new RegExp(e,"g"),((t,...e)=>{let a;e=e.slice(0,e.length-2);const s="pug"===this.language;let o=e.find(((t,e)=>t&&(a=n[e])&&t));if("quote"===a)o=this.unhtmlize(o);else if("comment"===a)if(s){const[t,a,s]=e.slice(n.indexOf("comment"));o=`${t}${a}${this.unhtmlize(s)}`}else o=this.unhtmlize(o);else{if("text"===a&&s)return`${e[0]}<span class="punctuation">|</span>${e[1]}<span class="text">${e[2]}</span>`;if("text2"===a&&s){const[,,,t,n,a]=e;return`${t}${this.syntaxHighlightContent(n)}<span class="punctuation">.</span>\n<span class="text">${a}</span>`}if("tag"===a&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(e.slice(n.indexOf("tag")));if("variable"===a&&"."===o[0]&&"js"===this.language)return`<span class="punctuation">.</span><span class="obj-attr">${o.substr(1)}</span>`}let i="";return"color"===a&&"css"===this.language&&(i=` style="background-color: ${o};color: #${this.isColorDark(o)?"fff":"000"}"`),a&&`<span class="${a}"${i}>${o}</span>`||""}))},checkSlots(){const t=(this.$slots.default||[]).map((t=>t.text||"")).join("");this.slotTexts!==t&&(this.slotTexts=t,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()},beforeUpdate(){this.reactive&&this.checkSlots()}},o={};var i=function(t,e,n,a,s,o,i,r){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),i?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(t,e){return l.call(e),u(t,e)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:t,options:c}}(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"ssh-pre",class:{"ssh-pre--dark":t.dark},attrs:{"data-type":t.language,"data-label":t.label||null}},[t.copyButton?n("button",{staticClass:"ssh-pre__copy",on:{click:t.copyCode}},[t._t("copy-button",(function(){return[t._v("Copy")]}))],2):t._e(),t._v(" "),n("pre",{ref:"code",staticClass:"ssh-pre__content",domProps:{innerHTML:t._s(t.content)}})])}),[],!1,(function(t){for(let e in o)this[e]=o[e]}),null,null,null);i.options.__file="src/components/simple-syntax-highlighter.vue";var r=i.exports;module.exports=r; |
@@ -1,1 +0,1 @@ | ||
const t={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,htmlTag:/(<([^>])*>)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},e={shell:{quote:t.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z\-:]+)([\s\S]*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-z]\w*)([\s\S]*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text2:/((?:^|\n)[ \t]+|^)\|([ \t]*)([^\n]+(?=\n|$))/,quote:t.quote,comment:/(?:^|\n)([ \t]+|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\1[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(([\s\S]*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:t.quote,comment:/(\/\*[\s\S]*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:t.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:t.quote,comment:t.comment,number:t.number,boolean:t.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:t.quote,comment:t.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:t.quote,comment:t.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:t.punctuation,number:t.number,boolean:t.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:t.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,punctuation:t.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},n={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')([\s\S]*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')([\s\S]*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g},a={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{quote:2,comment:2,text:4,text2:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},s={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(e),content:"",slotTexts:""}),methods:{htmlize:t=>t.replace(/&(lt|gt|amp);/g,((t,e)=>({lt:"<",gt:">",amp:"&"}[e]))),unhtmlize:t=>t.replace(/[<>]/g,(t=>({"<":"<",">":">"}[t]))),isColorDark(t){let e,n,a,s,o,i;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))a=parseInt(e[1])<=100,s=parseInt(e[2])<=100,o=parseInt(e[3])<=100,i=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const t=3===n[1].length;a=parseInt(n[1][0])<=9,s=parseInt(n[1][t?1:2])<=9,o=parseInt(n[1][t?2:4])<=9}return(a&&s&&o||a&&s&&!o||!a&&s&&o)&&!i},createRegexPattern(){let t="";const n=[];for(const s in e[this.language]){const o=a[this.language][s]||1;for(let t=0;t<o;t++)n.push(s);t+=(t?"|":"")+e[this.language][s].source}return[t,n]},syntaxHighlightHtmlTag(t){let e=(t[2]||"").replace(n[this.language],((t,e,n,a,s)=>`${e}<span class="attribute">${n}</span>`+(s?'<span class="punctuation">=</span>':"")+(s?`<span class="quote">${a||""}${s||""}${a||""}</span>`:"")));if("pug"===this.language){const n=(t[1]||"").replace(/\.[a-z\d-]+/g,(t=>`<span class="class">${t}</span>`));return e&&(e='<span class="punctuation">(</span>'+e+'<span class="punctuation">)</span>'),`<span class="tag-name">${t[0]||""}</span>${n}${e}`+(t[3]?'<span class="punctuation">.</span>':"")+(t[4]||"")+`${t[5]?t[5]:""}`}return`<span class="punctuation">${t[0]}</span><span class="tag-name">${t[1]}</span>`+e+`<span class="punctuation">${t[3]}</span>`},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t).replace(new RegExp(e,"g"),((t,...e)=>{let a,s=(e=e.slice(0,e.length-2)).find(((t,e)=>t&&(a=n[e])&&t));if("quote"===a)s=this.unhtmlize(s);else if("comment"===a)s=this.unhtmlize(s);else{if("text"===a&&"pug"===this.language)return`${e[0]}${e[1]}${e[2]}<span class="punctuation">.</span>\n<span class="text">${e[3]}</span>`;if("text2"===a&&"pug"===this.language)return`${e[0]}<span class="punctuation">|</span>${e[1]}<span class="text">${e[2]}</span>`;if("tag"===a&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(e.slice(n.indexOf("tag")));if("variable"===a&&"."===s[0]&&"js"===this.language)return`<span class="punctuation">.</span><span class="obj-attr">${s.substr(1)}</span>`}let o="";return"color"===a&&"css"===this.language&&(o=` style="background-color: ${s};color: #${this.isColorDark(s)?"fff":"000"}"`),a&&`<span class="${a}"${o}>${s}</span>`||""}))},checkSlots(){const t=(this.$slots.default||[]).map((t=>t.text||"")).join("");this.slotTexts!==t&&(this.slotTexts=t,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()},beforeUpdate(){this.reactive&&this.checkSlots()}},o={};var i=function(t,e,n,a,s,o,i,r){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),i?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(t,e){return l.call(e),u(t,e)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:t,options:c}}(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"ssh-pre",class:{"ssh-pre--dark":t.dark},attrs:{"data-type":t.language,"data-label":t.label||null}},[t.copyButton?n("button",{staticClass:"ssh-pre__copy",on:{click:t.copyCode}},[t._t("copy-button",(function(){return[t._v("Copy")]}))],2):t._e(),t._v(" "),n("pre",{ref:"code",staticClass:"ssh-pre__content",domProps:{innerHTML:t._s(t.content)}})])}),[],!1,(function(t){for(let e in o)this[e]=o[e]}),null,null,null);i.options.__file="src/components/simple-syntax-highlighter.vue";var r=i.exports;export default r; | ||
const t={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,htmlTag:/(<([^>])*>)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},e={shell:{quote:t.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z\-:]+)([\s\S]*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-z]\w*)([\s\S]*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\n|$))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\1[ \t]+)|(?=\1[ \t]+)[\s\S]+?(?:\n|$)*?)*)(?=\n|$)/,quote:t.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\1[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(([\s\S]*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:t.quote,comment:/(\/\*[\s\S]*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:t.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:t.quote,comment:t.comment,number:t.number,boolean:t.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:t.quote,comment:t.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:t.quote,comment:t.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:t.punctuation,number:t.number,boolean:t.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:t.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,punctuation:t.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},n={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')([\s\S]*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')([\s\S]*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g},a={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},s={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(e),content:"",slotTexts:""}),methods:{htmlize:t=>t.replace(/&(lt|gt|amp);/g,((t,e)=>({lt:"<",gt:">",amp:"&"}[e]))),unhtmlize:t=>t.replace(/[<>]/g,(t=>({"<":"<",">":">"}[t]))),isColorDark(t){let e,n,a,s,o,i;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))a=parseInt(e[1])<=100,s=parseInt(e[2])<=100,o=parseInt(e[3])<=100,i=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const t=3===n[1].length;a=parseInt(n[1][0])<=9,s=parseInt(n[1][t?1:2])<=9,o=parseInt(n[1][t?2:4])<=9}return(a&&s&&o||a&&s&&!o||!a&&s&&o)&&!i},createRegexPattern(){let t="";const n=[];for(const s in e[this.language]){const o=a[this.language][s]||1;for(let t=0;t<o;t++)n.push(s);t+=(t?"|":"")+e[this.language][s].source}return[t,n]},syntaxHighlightHtmlTag(t){let e=(t[2]||"").replace(n[this.language],((t,e,n,a,s)=>`${e}<span class="attribute">${n}</span>`+(s?'<span class="punctuation">=</span>':"")+(s?`<span class="quote">${a||""}${s||""}${a||""}</span>`:"")));if("pug"===this.language){const n=(t[1]||"").replace(/#[a-z\d-]+/g,(t=>`<span class="id">${t}</span>`)).replace(/\.[a-z\d-]+/g,(t=>`<span class="class">${t}</span>`));return e&&(e='<span class="punctuation">(</span>'+e+'<span class="punctuation">)</span>'),`<span class="tag-name">${t[0]||""}</span>${n}${e}`+(t[3]?'<span class="punctuation">.</span>':"")+(t[4]||"")+(t[5]?`<span class="text">${t[5]}</span>`:"")}return`<span class="punctuation">${t[0]}</span><span class="tag-name">${t[1]}</span>`+e+`<span class="punctuation">${t[3]}</span>`},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t).replace(new RegExp(e,"g"),((t,...e)=>{let a;e=e.slice(0,e.length-2);const s="pug"===this.language;let o=e.find(((t,e)=>t&&(a=n[e])&&t));if("quote"===a)o=this.unhtmlize(o);else if("comment"===a)if(s){const[t,a,s]=e.slice(n.indexOf("comment"));o=`${t}${a}${this.unhtmlize(s)}`}else o=this.unhtmlize(o);else{if("text"===a&&s)return`${e[0]}<span class="punctuation">|</span>${e[1]}<span class="text">${e[2]}</span>`;if("text2"===a&&s){const[,,,t,n,a]=e;return`${t}${this.syntaxHighlightContent(n)}<span class="punctuation">.</span>\n<span class="text">${a}</span>`}if("tag"===a&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(e.slice(n.indexOf("tag")));if("variable"===a&&"."===o[0]&&"js"===this.language)return`<span class="punctuation">.</span><span class="obj-attr">${o.substr(1)}</span>`}let i="";return"color"===a&&"css"===this.language&&(i=` style="background-color: ${o};color: #${this.isColorDark(o)?"fff":"000"}"`),a&&`<span class="${a}"${i}>${o}</span>`||""}))},checkSlots(){const t=(this.$slots.default||[]).map((t=>t.text||"")).join("");this.slotTexts!==t&&(this.slotTexts=t,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()},beforeUpdate(){this.reactive&&this.checkSlots()}},o={};var i=function(t,e,n,a,s,o,i,r){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),i?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(t,e){return l.call(e),u(t,e)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:t,options:c}}(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"ssh-pre",class:{"ssh-pre--dark":t.dark},attrs:{"data-type":t.language,"data-label":t.label||null}},[t.copyButton?n("button",{staticClass:"ssh-pre__copy",on:{click:t.copyCode}},[t._t("copy-button",(function(){return[t._v("Copy")]}))],2):t._e(),t._v(" "),n("pre",{ref:"code",staticClass:"ssh-pre__content",domProps:{innerHTML:t._s(t.content)}})])}),[],!1,(function(t){for(let e in o)this[e]=o[e]}),null,null,null);i.options.__file="src/components/simple-syntax-highlighter.vue";var r=i.exports;export default r; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).sshpre=t()}(this,(function(){"use strict";const e={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,htmlTag:/(<([^>])*>)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},t={shell:{quote:e.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:e.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z\-:]+)([\s\S]*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:e.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-z]\w*)([\s\S]*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:e.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text2:/((?:^|\n)[ \t]+|^)\|([ \t]*)([^\n]+(?=\n|$))/,quote:e.quote,comment:/(?:^|\n)([ \t]+|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\1[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(([\s\S]*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:e.quote,comment:/(\/\*[\s\S]*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:e.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:e.quote,comment:e.comment,number:e.number,boolean:e.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:e.quote,comment:e.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:e.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:e.quote,comment:e.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:e.punctuation,number:e.number,boolean:e.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:e.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,punctuation:e.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:e.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},n={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')([\s\S]*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')([\s\S]*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g},a={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{quote:2,comment:2,text:4,text2:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},s={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(t),content:"",slotTexts:""}),methods:{htmlize:e=>e.replace(/&(lt|gt|amp);/g,((e,t)=>({lt:"<",gt:">",amp:"&"}[t]))),unhtmlize:e=>e.replace(/[<>]/g,(e=>({"<":"<",">":">"}[e]))),isColorDark(e){let t,n,a,s,o,i;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))a=parseInt(t[1])<=100,s=parseInt(t[2])<=100,o=parseInt(t[3])<=100,i=parseFloat(t[4])<.3;else if(n=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const e=3===n[1].length;a=parseInt(n[1][0])<=9,s=parseInt(n[1][e?1:2])<=9,o=parseInt(n[1][e?2:4])<=9}return(a&&s&&o||a&&s&&!o||!a&&s&&o)&&!i},createRegexPattern(){let e="";const n=[];for(const s in t[this.language]){const o=a[this.language][s]||1;for(let e=0;e<o;e++)n.push(s);e+=(e?"|":"")+t[this.language][s].source}return[e,n]},syntaxHighlightHtmlTag(e){let t=(e[2]||"").replace(n[this.language],((e,t,n,a,s)=>`${t}<span class="attribute">${n}</span>`+(s?'<span class="punctuation">=</span>':"")+(s?`<span class="quote">${a||""}${s||""}${a||""}</span>`:"")));if("pug"===this.language){const n=(e[1]||"").replace(/\.[a-z\d-]+/g,(e=>`<span class="class">${e}</span>`));return t&&(t='<span class="punctuation">(</span>'+t+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${n}${t}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+`${e[5]?e[5]:""}`}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+t+`<span class="punctuation">${e[3]}</span>`},syntaxHighlightContent(e){if(!this.knownLanguages.includes(this.language))return e;const[t,n]=this.createRegexPattern();return this.unhtmlize(e).replace(new RegExp(t,"g"),((e,...t)=>{let a,s=(t=t.slice(0,t.length-2)).find(((e,t)=>e&&(a=n[t])&&e));if("quote"===a)s=this.unhtmlize(s);else if("comment"===a)s=this.unhtmlize(s);else{if("text"===a&&"pug"===this.language)return`${t[0]}${t[1]}${t[2]}<span class="punctuation">.</span>\n<span class="text">${t[3]}</span>`;if("text2"===a&&"pug"===this.language)return`${t[0]}<span class="punctuation">|</span>${t[1]}<span class="text">${t[2]}</span>`;if("tag"===a&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(t.slice(n.indexOf("tag")));if("variable"===a&&"."===s[0]&&"js"===this.language)return`<span class="punctuation">.</span><span class="obj-attr">${s.substr(1)}</span>`}let o="";return"color"===a&&"css"===this.language&&(o=` style="background-color: ${s};color: #${this.isColorDark(s)?"fff":"000"}"`),a&&`<span class="${a}"${o}>${s}</span>`||""}))},checkSlots(){const e=(this.$slots.default||[]).map((e=>e.text||"")).join("");this.slotTexts!==e&&(this.slotTexts=e,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(e){e.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const t=document.getElementById("clipboard-textarea");t.select(),t.setSelectionRange(0,99999),document.execCommand("copy"),t.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()},beforeUpdate(){this.reactive&&this.checkSlots()}},o={};var i=function(e,t,n,a,s,o,i,r){var l,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),s&&s.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(e,t){return l.call(t),u(e,t)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:e,options:c}}(s,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"ssh-pre",class:{"ssh-pre--dark":e.dark},attrs:{"data-type":e.language,"data-label":e.label||null}},[e.copyButton?n("button",{staticClass:"ssh-pre__copy",on:{click:e.copyCode}},[e._t("copy-button",(function(){return[e._v("Copy")]}))],2):e._e(),e._v(" "),n("pre",{ref:"code",staticClass:"ssh-pre__content",domProps:{innerHTML:e._s(e.content)}})])}),[],!1,(function(e){for(let t in o)this[t]=o[t]}),null,null,null);return i.options.__file="src/components/simple-syntax-highlighter.vue",i.exports})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).sshpre=e()}(this,(function(){"use strict";const t={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,htmlTag:/(<([^>])*>)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},e={shell:{quote:t.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z\-:]+)([\s\S]*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-z]\w*)([\s\S]*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:t.quote,comment:/(<!--[\s\S]*?-->)/,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\n|$))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\1[ \t]+)|(?=\1[ \t]+)[\s\S]+?(?:\n|$)*?)*)(?=\n|$)/,quote:t.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\1[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(([\s\S]*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:t.quote,comment:/(\/\*[\s\S]*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:t.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:t.quote,comment:t.comment,number:t.number,boolean:t.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:t.quote,comment:t.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:t.quote,comment:t.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:t.punctuation,number:t.number,boolean:t.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:t.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*[\s\S]*?\*\/)/,punctuation:t.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:t.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},n={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')([\s\S]*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')([\s\S]*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')([\s\S]*?)\3)|)/g},a={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},s={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(e),content:"",slotTexts:""}),methods:{htmlize:t=>t.replace(/&(lt|gt|amp);/g,((t,e)=>({lt:"<",gt:">",amp:"&"}[e]))),unhtmlize:t=>t.replace(/[<>]/g,(t=>({"<":"<",">":">"}[t]))),isColorDark(t){let e,n,a,s,o,i;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))a=parseInt(e[1])<=100,s=parseInt(e[2])<=100,o=parseInt(e[3])<=100,i=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const t=3===n[1].length;a=parseInt(n[1][0])<=9,s=parseInt(n[1][t?1:2])<=9,o=parseInt(n[1][t?2:4])<=9}return(a&&s&&o||a&&s&&!o||!a&&s&&o)&&!i},createRegexPattern(){let t="";const n=[];for(const s in e[this.language]){const o=a[this.language][s]||1;for(let t=0;t<o;t++)n.push(s);t+=(t?"|":"")+e[this.language][s].source}return[t,n]},syntaxHighlightHtmlTag(t){let e=(t[2]||"").replace(n[this.language],((t,e,n,a,s)=>`${e}<span class="attribute">${n}</span>`+(s?'<span class="punctuation">=</span>':"")+(s?`<span class="quote">${a||""}${s||""}${a||""}</span>`:"")));if("pug"===this.language){const n=(t[1]||"").replace(/#[a-z\d-]+/g,(t=>`<span class="id">${t}</span>`)).replace(/\.[a-z\d-]+/g,(t=>`<span class="class">${t}</span>`));return e&&(e='<span class="punctuation">(</span>'+e+'<span class="punctuation">)</span>'),`<span class="tag-name">${t[0]||""}</span>${n}${e}`+(t[3]?'<span class="punctuation">.</span>':"")+(t[4]||"")+(t[5]?`<span class="text">${t[5]}</span>`:"")}return`<span class="punctuation">${t[0]}</span><span class="tag-name">${t[1]}</span>`+e+`<span class="punctuation">${t[3]}</span>`},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t).replace(new RegExp(e,"g"),((t,...e)=>{let a;e=e.slice(0,e.length-2);const s="pug"===this.language;let o=e.find(((t,e)=>t&&(a=n[e])&&t));if("quote"===a)o=this.unhtmlize(o);else if("comment"===a)if(s){const[t,a,s]=e.slice(n.indexOf("comment"));o=`${t}${a}${this.unhtmlize(s)}`}else o=this.unhtmlize(o);else{if("text"===a&&s)return`${e[0]}<span class="punctuation">|</span>${e[1]}<span class="text">${e[2]}</span>`;if("text2"===a&&s){const[,,,t,n,a]=e;return`${t}${this.syntaxHighlightContent(n)}<span class="punctuation">.</span>\n<span class="text">${a}</span>`}if("tag"===a&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(e.slice(n.indexOf("tag")));if("variable"===a&&"."===o[0]&&"js"===this.language)return`<span class="punctuation">.</span><span class="obj-attr">${o.substr(1)}</span>`}let i="";return"color"===a&&"css"===this.language&&(i=` style="background-color: ${o};color: #${this.isColorDark(o)?"fff":"000"}"`),a&&`<span class="${a}"${i}>${o}</span>`||""}))},checkSlots(){const t=(this.$slots.default||[]).map((t=>t.text||"")).join("");this.slotTexts!==t&&(this.slotTexts=t,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()},beforeUpdate(){this.reactive&&this.checkSlots()}},o={};var i=function(t,e,n,a,s,o,i,r){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),i?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var u=c.render;c.render=function(t,e){return l.call(e),u(t,e)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:t,options:c}}(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"ssh-pre",class:{"ssh-pre--dark":t.dark},attrs:{"data-type":t.language,"data-label":t.label||null}},[t.copyButton?n("button",{staticClass:"ssh-pre__copy",on:{click:t.copyCode}},[t._t("copy-button",(function(){return[t._v("Copy")]}))],2):t._e(),t._v(" "),n("pre",{ref:"code",staticClass:"ssh-pre__content",domProps:{innerHTML:t._s(t.content)}})])}),[],!1,(function(t){for(let e in o)this[e]=o[e]}),null,null,null);return i.options.__file="src/components/simple-syntax-highlighter.vue",i.exports})); |
{ | ||
"name": "simple-syntax-highlighter", | ||
"version": "1.4.9", | ||
"version": "1.4.10", | ||
"description": "A Vue.js syntax highlighter that reads the source code you give it and highlights it, for Humans.", | ||
@@ -5,0 +5,0 @@ "author": "Antoni Andre <antoniandre.web@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
44833
136