simple-syntax-highlighter
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -1,2 +0,2 @@ | ||
"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:/(&[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,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:/(<\!DOCTYPE.*?>)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-z]\w*)(.*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},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:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},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]|>)+)(?=\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:/([:,;{}@#()!]+|<|>)/,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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(<\?php|\?>|__(?: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=>({"<":"<",">":">"})[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> | ||
"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:/(&[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,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:/(<\!DOCTYPE.*?>)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-z]\w*)(.*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},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:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},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]|>)+)(?=\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:/([:,;{}@#()!]+|<|>)/,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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(<\?php|\?>|__(?: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=>({"<":"<",">":">"})[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; |
@@ -60,3 +60,3 @@ import { openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, createElementVNode, createTextVNode } from "vue"; | ||
"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)/, | ||
"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\-]+)/, | ||
@@ -63,0 +63,0 @@ selector: /((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/, |
@@ -1,2 +0,2 @@ | ||
(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:/(&[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,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:/(<\!DOCTYPE.*?>)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-z]\w*)(.*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},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:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},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]|>)+)(?=\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:/([:,;{}@#()!]+|<|>)/,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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(<\?php|\?>|__(?: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=>({"<":"<",">":">"})[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> | ||
(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:/(&[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,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:/(<\!DOCTYPE.*?>)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-z]\w*)(.*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},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:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},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]|>)+)(?=\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:/([:,;{}@#()!]+|<|>)/,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:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(<\?php|\?>|__(?: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=>({"<":"<",">":">"})[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.1", | ||
"description": "A Vue.js syntax highlighter that reads the source code you give it and highlights it, for Humans.", | ||
"version": "2.2.2", | ||
"description": "A Vue.js syntax highlighter that reads the source code you provide and highlights it, for Humans.", | ||
"author": "Antoni Andre <antoniandre.web@gmail.com>", | ||
@@ -17,8 +17,8 @@ "homepage": "https://antoniandre.github.io/simple-syntax-highlighter", | ||
"exports": { | ||
"./dist/sshpre.css": "./dist/sshpre.css", | ||
"./dist/sshpre.cjs.js": "./dist/sshpre.cjs.js", | ||
".": { | ||
"import": "./dist/sshpre.es.js", | ||
"require": "./dist/sshpre.umd.js" | ||
} | ||
}, | ||
"./package.json": "./package.json", | ||
"./dist/*": "./dist/*" | ||
}, | ||
@@ -25,0 +25,0 @@ "keywords": [ |
@@ -7,3 +7,3 @@ # Simple Syntax Highlighter | ||
<!-- [![npm](https://img.shields.io/npm/dw/simple-syntax-highlighter.svg)](https://www.npmjs.com/package/simple-syntax-highlighter) --> | ||
> A very lightweight and easy to use syntax highlighter (not an editor) for Vue.js and Vue 3. Multiple coding languages supported. | ||
> A very lightweight and easy to use syntax highlighter (not an editor) for Vue 3 and 2. Multiple coding languages supported. | ||
> What I use in all my libs documentations. ;) | ||
@@ -19,6 +19,6 @@ | ||
**Vue 3** | ||
**Vue 2 (legacy)** | ||
``` | ||
npm i simple-syntax-highlighter@next | ||
npm i simple-syntax-highlighter@legacy | ||
``` | ||
@@ -46,2 +46,5 @@ ___ | ||
If you are using this library for profit business, please consider [backing me](https://github.com/sponsors/antoniandre)! | ||
It ensures that the project your products rely on keep being actively maintained. :) | ||
___ | ||
@@ -57,2 +60,3 @@ | ||
- __Version 2.0.0__ Vue 3 build | ||
- __Version 1.5.0__ Removed support for IE - it's finally over. :tada: | ||
@@ -59,0 +63,0 @@ - __Version 1.4.0__ Added Pug language support |
48306
405
64