Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-syntax-highlighter

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-syntax-highlighter - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

4

dist/sshpre.cjs.js

@@ -1,2 +0,2 @@

"use strict";var c=require("vue");var f=(e,t)=>{for(const[a,i]of t)e[a]=i;return e};const s={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/,htmlTag:/(<([^>])*>)/,htmlentity:/(&amp;[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|&lt;|&gt;)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},m={shell:{quote:s.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(&lt;\!DOCTYPE.*?&gt;)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z\-:]+)(.*?)(\/?&gt;)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-z]\w*)(.*?)(\/?&gt;)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?&gt;)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:s.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|&lt;|&gt;)+)/},css:{quote:s.quote,comment:/(\/\*.*?\*\/)/,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]|&gt;)+)(?=\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:s.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|&lt;|&gt;)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:s.quote,comment:s.comment,number:s.number,boolean:s.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:s.quote,comment:s.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|&lt;|&gt;)+|\.+(?![a-zA-Z])|&amp;&amp;|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(&lt;\?php|\?&gt;|__(?:DIR|FILE|LINE)__)/,punctuation:s.punctuation,number:s.number,boolean:s.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:s.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:s.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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/}},y={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},x={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}},g=e=>e.map(t=>{if(!t.children||typeof t.children=="string")return t.children||"";if(Array.isArray(t.children))return g(t.children);if(t.children.default)return g(t.children.default())}).join(""),E={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(m),content:"",slotTexts:""}),methods:{htmlize(e){return e.replace(/&(lt|gt|amp);/g,(t,a)=>({lt:"<",gt:">",amp:"&"})[a])},unhtmlize(e){return e.replace(/[<>]/g,t=>({"<":"&lt;",">":"&gt;"})[t])},isColorDark(e){let t,a,i,n,o,l;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))i=parseInt(t[1])<=100,n=parseInt(t[2])<=100,o=parseInt(t[3])<=100,l=parseFloat(t[4])<.3;else if(a=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const r=a[1].length===3;i=parseInt(a[1][0])<=9,n=parseInt(a[1][r?1:2])<=9,o=parseInt(a[1][r?2:4])<=9}return(i&&n&&o||i&&n&&!o||!i&&n&&o)&&!l},createRegexPattern(){let e="";const t=[];for(const a in m[this.language]){const i=x[this.language][a]||1;for(let n=0;n<i;n++)t.push(a);e+=(e?"|":"")+m[this.language][a].source}return[e,t]},syntaxHighlightHtmlTag(e){const t=(i,n,o,l,r)=>`${n}<span class="attribute">${o}</span>`+(r?'<span class="punctuation">=</span>':"")+(r?`<span class="quote">${l||""}${r||""}${l||""}</span>`:"");let a=(e[2]||"").replace(y[this.language],t);if(this.language==="pug"){const i=(e[1]||"").replace(/#[a-z\d-]+/g,n=>`<span class="id">${n}</span>`).replace(/\.[a-z\d-]+/g,n=>`<span class="class">${n}</span>`);return a&&(a='<span class="punctuation">(</span>'+a+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${i}${a}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+(e[5]?`<span class="text">${e[5]}</span>`:"")}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+a+`<span class="punctuation">${e[3]}</span>`},syntaxHighlightContent(e){if(!this.knownLanguages.includes(this.language))return e;const[t,a]=this.createRegexPattern();return this.unhtmlize(e).replace(new RegExp(t,"gs"),(i,...n)=>{n=n.slice(0,n.length-2);let o;const l=this.language==="pug";let r=n.find((u,d)=>u&&(o=a[d])&&u);if(o==="quote")r=this.unhtmlize(r);else if(o==="comment")if(l){const[u,d,p]=n.slice(a.indexOf("comment"));r=`${u}${d}${this.unhtmlize(p)}`}else r=this.unhtmlize(r);else{if(o==="text"&&l)return`${n[0]}<span class="punctuation">|</span>${n[1]}<span class="text">${n[2]}</span>`;if(o==="text2"&&l){const[,,,u,d,p]=n,b=this.syntaxHighlightContent(d);return`${u}${b}<span class="punctuation">.</span>
<span class="text">${p}</span>`}else{if(o==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(n.slice(a.indexOf("tag")));if(o==="variable"&&r[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${r.substr(1)}</span>`}}let h="";return o==="color"&&this.language==="css"&&(h=` style="background-color: ${r};color: #${this.isColorDark(r)?"fff":"000"}"`),o&&`<span class="${o}"${h}>${r}</span>`||""})},checkSlots(){const e=this.$slots.default&&g(this.$slots.default())||"";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()}},v=["data-type","data-label"],w=c.createTextVNode("Copy"),T=c.createTextVNode(),k=["innerHTML"];function $(e,t,a,i,n,o){return c.openBlock(),c.createElementBlock("div",{class:c.normalizeClass(["ssh-pre",{"ssh-pre--dark":a.dark}]),"data-type":a.language,"data-label":a.label||null},[a.copyButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:t[0]||(t[0]=(...l)=>o.copyCode&&o.copyCode(...l))},[c.renderSlot(e.$slots,"copy-button",{},()=>[w])])):c.createCommentVNode("",!0),T,c.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",innerHTML:e.content},null,8,k)],10,v)}var A=f(E,[["render",$]]);module.exports=A;
"use strict";var c=require("vue");var f=(e,t)=>{const a=e.__vccOpts||e;for(const[i,n]of t)a[i]=n;return a};const s={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/,htmlTag:/(<([^>])*>)/,htmlentity:/(&amp;[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|&lt;|&gt;)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},m={shell:{quote:s.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(&lt;\!DOCTYPE.*?&gt;)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z\-:]+)(.*?)(\/?&gt;)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-z]\w*)(.*?)(\/?&gt;)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?&gt;)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:s.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|&lt;|&gt;)+)/},css:{quote:s.quote,comment:/(\/\*.*?\*\/)/,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]|&gt;)+)(?=\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:s.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|&lt;|&gt;)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:s.quote,comment:s.comment,number:s.number,boolean:s.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:s.quote,comment:s.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|&lt;|&gt;)+|\.+(?![a-zA-Z])|&amp;&amp;|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(&lt;\?php|\?&gt;|__(?:DIR|FILE|LINE)__)/,punctuation:s.punctuation,number:s.number,boolean:s.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:s.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:s.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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/}},y={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},x={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}},g=e=>e.map(t=>{if(!t.children||typeof t.children=="string")return t.children||"";if(Array.isArray(t.children))return g(t.children);if(t.children.default)return g(t.children.default())}).join(""),E={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(m),content:"",slotTexts:""}),methods:{htmlize(e){return e.replace(/&(lt|gt|amp);/g,(t,a)=>({lt:"<",gt:">",amp:"&"})[a])},unhtmlize(e){return e.replace(/[<>]/g,t=>({"<":"&lt;",">":"&gt;"})[t])},isColorDark(e){let t,a,i,n,o,l;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))i=parseInt(t[1])<=100,n=parseInt(t[2])<=100,o=parseInt(t[3])<=100,l=parseFloat(t[4])<.3;else if(a=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const r=a[1].length===3;i=parseInt(a[1][0])<=9,n=parseInt(a[1][r?1:2])<=9,o=parseInt(a[1][r?2:4])<=9}return(i&&n&&o||i&&n&&!o||!i&&n&&o)&&!l},createRegexPattern(){let e="";const t=[];for(const a in m[this.language]){const i=x[this.language][a]||1;for(let n=0;n<i;n++)t.push(a);e+=(e?"|":"")+m[this.language][a].source}return[e,t]},syntaxHighlightHtmlTag(e){const t=(i,n,o,l,r)=>`${n}<span class="attribute">${o}</span>`+(r?'<span class="punctuation">=</span>':"")+(r?`<span class="quote">${l||""}${r||""}${l||""}</span>`:"");let a=(e[2]||"").replace(y[this.language],t);if(this.language==="pug"){const i=(e[1]||"").replace(/#[a-z\d-]+/g,n=>`<span class="id">${n}</span>`).replace(/\.[a-z\d-]+/g,n=>`<span class="class">${n}</span>`);return a&&(a='<span class="punctuation">(</span>'+a+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${i}${a}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+(e[5]?`<span class="text">${e[5]}</span>`:"")}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+a+`<span class="punctuation">${e[3]}</span>`},syntaxHighlightContent(e){if(!this.knownLanguages.includes(this.language))return e;const[t,a]=this.createRegexPattern();return this.unhtmlize(e).replace(new RegExp(t,"gs"),(i,...n)=>{n=n.slice(0,n.length-2);let o;const l=this.language==="pug";let r=n.find((u,d)=>u&&(o=a[d])&&u);if(o==="quote")r=this.unhtmlize(r);else if(o==="comment")if(l){const[u,d,p]=n.slice(a.indexOf("comment"));r=`${u}${d}${this.unhtmlize(p)}`}else r=this.unhtmlize(r);else{if(o==="text"&&l)return`${n[0]}<span class="punctuation">|</span>${n[1]}<span class="text">${n[2]}</span>`;if(o==="text2"&&l){const[,,,u,d,p]=n,b=this.syntaxHighlightContent(d);return`${u}${b}<span class="punctuation">.</span>
<span class="text">${p}</span>`}else{if(o==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(n.slice(a.indexOf("tag")));if(o==="variable"&&r[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${r.substr(1)}</span>`}}let h="";return o==="color"&&this.language==="css"&&(h=` style="background-color: ${r};color: #${this.isColorDark(r)?"fff":"000"}"`),o&&`<span class="${o}"${h}>${r}</span>`||""})},checkSlots(){const e=this.$slots.default&&g(this.$slots.default())||"";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()}},v=["data-type","data-label","reactive"],w=c.createTextVNode("Copy"),T=c.createTextVNode(),k=["innerHTML"];function $(e,t,a,i,n,o){return c.openBlock(),c.createElementBlock("div",{class:c.normalizeClass(["ssh-pre",{"ssh-pre--dark":a.dark}]),"data-type":a.language,"data-label":a.label||null,reactive:a.reactive&&o.checkSlots()||null},[a.copyButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:t[0]||(t[0]=(...l)=>o.copyCode&&o.copyCode(...l))},[c.renderSlot(e.$slots,"copy-button",{},()=>[w])])):c.createCommentVNode("",!0),T,c.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",innerHTML:e.content},null,8,k)],10,v)}var A=f(E,[["render",$]]);module.exports=A;
import { openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, createElementVNode, createTextVNode } from "vue";
var simpleSyntaxHighlighter_vue_vue_type_style_index_0_lang = "";
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
sfc[key] = val;
target[key] = val;
}
return sfc;
return target;
};

@@ -242,3 +243,6 @@ const regexBasics = {

copyCode(e) {
e.target.insertAdjacentHTML("afterend", `<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);
e.target.insertAdjacentHTML(
"afterend",
`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`
);
const textarea = document.getElementById("clipboard-textarea");

@@ -254,9 +258,5 @@ textarea.select();

this.checkSlots();
},
beforeUpdate() {
if (this.reactive)
this.checkSlots();
}
};
const _hoisted_1 = ["data-type", "data-label"];
const _hoisted_1 = ["data-type", "data-label", "reactive"];
const _hoisted_2 = /* @__PURE__ */ createTextVNode("Copy");

@@ -269,3 +269,4 @@ const _hoisted_3 = /* @__PURE__ */ createTextVNode();

"data-type": $props.language,
"data-label": $props.label || null
"data-label": $props.label || null,
reactive: $props.reactive && $options.checkSlots() || null
}, [

@@ -272,0 +273,0 @@ $props.copyButton ? (openBlock(), createElementBlock("button", {

@@ -1,2 +0,2 @@

(function(r,p){typeof exports=="object"&&typeof module!="undefined"?module.exports=p(require("vue")):typeof define=="function"&&define.amd?define(["vue"],p):(r=typeof globalThis!="undefined"?globalThis:r||self,r.sshpre=p(r.Vue))})(this,function(r){"use strict";var p="",b=(e,t)=>{for(const[n,l]of t)e[n]=l;return e};const s={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/,htmlTag:/(<([^>])*>)/,htmlentity:/(&amp;[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|&lt;|&gt;)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},m={shell:{quote:s.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(&lt;\!DOCTYPE.*?&gt;)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z\-:]+)(.*?)(\/?&gt;)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-z]\w*)(.*?)(\/?&gt;)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?&gt;)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:s.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|&lt;|&gt;)+)/},css:{quote:s.quote,comment:/(\/\*.*?\*\/)/,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]|&gt;)+)(?=\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:s.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|&lt;|&gt;)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:s.quote,comment:s.comment,number:s.number,boolean:s.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:s.quote,comment:s.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|&lt;|&gt;)+|\.+(?![a-zA-Z])|&amp;&amp;|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(&lt;\?php|\?&gt;|__(?:DIR|FILE|LINE)__)/,punctuation:s.punctuation,number:s.number,boolean:s.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:s.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:s.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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/}},y={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},x={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}},g=e=>e.map(t=>{if(!t.children||typeof t.children=="string")return t.children||"";if(Array.isArray(t.children))return g(t.children);if(t.children.default)return g(t.children.default())}).join(""),E={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(m),content:"",slotTexts:""}),methods:{htmlize(e){return e.replace(/&(lt|gt|amp);/g,(t,n)=>({lt:"<",gt:">",amp:"&"})[n])},unhtmlize(e){return e.replace(/[<>]/g,t=>({"<":"&lt;",">":"&gt;"})[t])},isColorDark(e){let t,n,l,a,o,c;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))l=parseInt(t[1])<=100,a=parseInt(t[2])<=100,o=parseInt(t[3])<=100,c=parseFloat(t[4])<.3;else if(n=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const i=n[1].length===3;l=parseInt(n[1][0])<=9,a=parseInt(n[1][i?1:2])<=9,o=parseInt(n[1][i?2:4])<=9}return(l&&a&&o||l&&a&&!o||!l&&a&&o)&&!c},createRegexPattern(){let e="";const t=[];for(const n in m[this.language]){const l=x[this.language][n]||1;for(let a=0;a<l;a++)t.push(n);e+=(e?"|":"")+m[this.language][n].source}return[e,t]},syntaxHighlightHtmlTag(e){const t=(l,a,o,c,i)=>`${a}<span class="attribute">${o}</span>`+(i?'<span class="punctuation">=</span>':"")+(i?`<span class="quote">${c||""}${i||""}${c||""}</span>`:"");let n=(e[2]||"").replace(y[this.language],t);if(this.language==="pug"){const l=(e[1]||"").replace(/#[a-z\d-]+/g,a=>`<span class="id">${a}</span>`).replace(/\.[a-z\d-]+/g,a=>`<span class="class">${a}</span>`);return n&&(n='<span class="punctuation">(</span>'+n+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${l}${n}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+(e[5]?`<span class="text">${e[5]}</span>`:"")}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+n+`<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,"gs"),(l,...a)=>{a=a.slice(0,a.length-2);let o;const c=this.language==="pug";let i=a.find((u,d)=>u&&(o=n[d])&&u);if(o==="quote")i=this.unhtmlize(i);else if(o==="comment")if(c){const[u,d,h]=a.slice(n.indexOf("comment"));i=`${u}${d}${this.unhtmlize(h)}`}else i=this.unhtmlize(i);else{if(o==="text"&&c)return`${a[0]}<span class="punctuation">|</span>${a[1]}<span class="text">${a[2]}</span>`;if(o==="text2"&&c){const[,,,u,d,h]=a,_=this.syntaxHighlightContent(d);return`${u}${_}<span class="punctuation">.</span>
<span class="text">${h}</span>`}else{if(o==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag")));if(o==="variable"&&i[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${i.substr(1)}</span>`}}let f="";return o==="color"&&this.language==="css"&&(f=` style="background-color: ${i};color: #${this.isColorDark(i)?"fff":"000"}"`),o&&`<span class="${o}"${f}>${i}</span>`||""})},checkSlots(){const e=this.$slots.default&&g(this.$slots.default())||"";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()}},w=["data-type","data-label"],T=r.createTextVNode("Copy"),k=r.createTextVNode(),v=["innerHTML"];function $(e,t,n,l,a,o){return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["ssh-pre",{"ssh-pre--dark":n.dark}]),"data-type":n.language,"data-label":n.label||null},[n.copyButton?(r.openBlock(),r.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:t[0]||(t[0]=(...c)=>o.copyCode&&o.copyCode(...c))},[r.renderSlot(e.$slots,"copy-button",{},()=>[T])])):r.createCommentVNode("",!0),k,r.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",innerHTML:e.content},null,8,v)],10,w)}var A=b(E,[["render",$]]);return A});
(function(i,p){typeof exports=="object"&&typeof module!="undefined"?module.exports=p(require("vue")):typeof define=="function"&&define.amd?define(["vue"],p):(i=typeof globalThis!="undefined"?globalThis:i||self,i.sshpre=p(i.Vue))})(this,function(i){"use strict";var p="",b=(e,t)=>{const n=e.__vccOpts||e;for(const[l,a]of t)n[l]=a;return n};const s={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/,htmlTag:/(<([^>])*>)/,htmlentity:/(&amp;[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|&lt;|&gt;)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},m={shell:{quote:s.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(&lt;\!DOCTYPE.*?&gt;)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z\-:]+)(.*?)(\/?&gt;)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-z]\w*)(.*?)(\/?&gt;)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(&lt;!--.*?--&gt;)/,htmlentity:s.htmlentity,tag:/(&lt;\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?&gt;)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:s.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|&lt;|&gt;)+)/},css:{quote:s.quote,comment:/(\/\*.*?\*\/)/,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]|&gt;)+)(?=\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:s.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|&lt;|&gt;)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:s.quote,comment:s.comment,number:s.number,boolean:s.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:s.quote,comment:s.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|&lt;|&gt;)+|\.+(?![a-zA-Z])|&amp;&amp;|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(&lt;\?php|\?&gt;|__(?:DIR|FILE|LINE)__)/,punctuation:s.punctuation,number:s.number,boolean:s.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:s.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:s.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.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/}},y={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},x={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}},g=e=>e.map(t=>{if(!t.children||typeof t.children=="string")return t.children||"";if(Array.isArray(t.children))return g(t.children);if(t.children.default)return g(t.children.default())}).join(""),E={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(m),content:"",slotTexts:""}),methods:{htmlize(e){return e.replace(/&(lt|gt|amp);/g,(t,n)=>({lt:"<",gt:">",amp:"&"})[n])},unhtmlize(e){return e.replace(/[<>]/g,t=>({"<":"&lt;",">":"&gt;"})[t])},isColorDark(e){let t,n,l,a,o,c;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))l=parseInt(t[1])<=100,a=parseInt(t[2])<=100,o=parseInt(t[3])<=100,c=parseFloat(t[4])<.3;else if(n=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const r=n[1].length===3;l=parseInt(n[1][0])<=9,a=parseInt(n[1][r?1:2])<=9,o=parseInt(n[1][r?2:4])<=9}return(l&&a&&o||l&&a&&!o||!l&&a&&o)&&!c},createRegexPattern(){let e="";const t=[];for(const n in m[this.language]){const l=x[this.language][n]||1;for(let a=0;a<l;a++)t.push(n);e+=(e?"|":"")+m[this.language][n].source}return[e,t]},syntaxHighlightHtmlTag(e){const t=(l,a,o,c,r)=>`${a}<span class="attribute">${o}</span>`+(r?'<span class="punctuation">=</span>':"")+(r?`<span class="quote">${c||""}${r||""}${c||""}</span>`:"");let n=(e[2]||"").replace(y[this.language],t);if(this.language==="pug"){const l=(e[1]||"").replace(/#[a-z\d-]+/g,a=>`<span class="id">${a}</span>`).replace(/\.[a-z\d-]+/g,a=>`<span class="class">${a}</span>`);return n&&(n='<span class="punctuation">(</span>'+n+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${l}${n}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+(e[5]?`<span class="text">${e[5]}</span>`:"")}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+n+`<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,"gs"),(l,...a)=>{a=a.slice(0,a.length-2);let o;const c=this.language==="pug";let r=a.find((u,d)=>u&&(o=n[d])&&u);if(o==="quote")r=this.unhtmlize(r);else if(o==="comment")if(c){const[u,d,h]=a.slice(n.indexOf("comment"));r=`${u}${d}${this.unhtmlize(h)}`}else r=this.unhtmlize(r);else{if(o==="text"&&c)return`${a[0]}<span class="punctuation">|</span>${a[1]}<span class="text">${a[2]}</span>`;if(o==="text2"&&c){const[,,,u,d,h]=a,_=this.syntaxHighlightContent(d);return`${u}${_}<span class="punctuation">.</span>
<span class="text">${h}</span>`}else{if(o==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag")));if(o==="variable"&&r[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${r.substr(1)}</span>`}}let f="";return o==="color"&&this.language==="css"&&(f=` style="background-color: ${r};color: #${this.isColorDark(r)?"fff":"000"}"`),o&&`<span class="${o}"${f}>${r}</span>`||""})},checkSlots(){const e=this.$slots.default&&g(this.$slots.default())||"";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()}},w=["data-type","data-label","reactive"],T=i.createTextVNode("Copy"),k=i.createTextVNode(),v=["innerHTML"];function $(e,t,n,l,a,o){return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["ssh-pre",{"ssh-pre--dark":n.dark}]),"data-type":n.language,"data-label":n.label||null,reactive:n.reactive&&o.checkSlots()||null},[n.copyButton?(i.openBlock(),i.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:t[0]||(t[0]=(...c)=>o.copyCode&&o.copyCode(...c))},[i.renderSlot(e.$slots,"copy-button",{},()=>[T])])):i.createCommentVNode("",!0),k,i.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",innerHTML:e.content},null,8,v)],10,w)}var A=b(E,[["render",$]]);return A});
{
"name": "simple-syntax-highlighter",
"version": "2.2.0",
"version": "2.2.1",
"description": "A Vue.js syntax highlighter that reads the source code you give it and highlights it, for Humans.",
"author": "Antoni Andre <antoniandre.web@gmail.com>",
"homepage": "https://antoniandre.github.io/simple-syntax-highlighter",
"repository": "https://github.com/antoniandre/simple-syntax-highlighter",
"license": "MIT",
"funding": "https://github.com/sponsors/antoniandre",
"main": "dist/sshpre.cjs.js",

@@ -30,3 +33,2 @@ "unpkg": "dist/sshpre.umd.js",

],
"license": "MIT",
"scripts": {

@@ -39,19 +41,22 @@ "dev": "vite",

"devDependencies": {
"@babel/eslint-parser": "^7.15.8",
"@vitejs/plugin-vue": "^1.9.4",
"@vue/compiler-sfc": "^3.2.20",
"@babel/eslint-parser": "^7.18.9",
"@vitejs/plugin-vue": "^1.10.2",
"@vue/compiler-sfc": "^3.2.37",
"@vue/eslint-config-standard": "^6.1.0",
"autoprefixer": "^10.3.7",
"autoprefixer": "^10.4.7",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-vue": "^7.20.0",
"rollup-plugin-delete": "^2.0.0",
"sass": "^1.43.4",
"vite": "^2.6.13",
"vite-plugin-pug": "^0.3.0",
"vue": "^3.2.20",
"wave-ui": "^2.25.0"
"sass": "^1.54.0",
"vite": "^2.9.14",
"vite-plugin-pug": "^0.3.1",
"vue": "^3.2.37",
"wave-ui": "^2.40.2"
},
"peerDependencies": {
"vue": "^2.6.14 || ^3.2.0"
},
"postcss": {

@@ -58,0 +63,0 @@ "plugins": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc