WordPress/wp-includes/js/shortcode.min.js

2 lines
2.6 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
window.wp=window.wp||{},wp.shortcode={next:function(t,e,n){var s,r,o=wp.shortcode.regexp(t);if(o.lastIndex=n||0,s=o.exec(e))return"["===s[1]&&"]"===s[7]?wp.shortcode.next(t,e,o.lastIndex):(r={index:s.index,content:s[0],shortcode:wp.shortcode.fromMatch(s)},s[1]&&(r.content=r.content.slice(1),r.index++),s[7]&&(r.content=r.content.slice(0,-1)),r)},replace:function(t,e,h){return e.replace(wp.shortcode.regexp(t),function(t,e,n,s,r,o,i,c){if("["===e&&"]"===c)return t;var a=h(wp.shortcode.fromMatch(arguments));return a?e+a+c:t})},string:function(t){return new wp.shortcode(t).string()},regexp:_.memoize(function(t){return new RegExp("\\[(\\[?)("+t+")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)","g")}),attrs:_.memoize(function(t){var e,n,s={},r=[];for(e=/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g,t=t.replace(/[\u00a0\u200b]/g," ");n=e.exec(t);)n[1]?s[n[1].toLowerCase()]=n[2]:n[3]?s[n[3].toLowerCase()]=n[4]:n[5]?s[n[5].toLowerCase()]=n[6]:n[7]?r.push(n[7]):n[8]?r.push(n[8]):n[9]&&r.push(n[9]);return{named:s,numeric:r}}),fromMatch:function(t){var e;return e=t[4]?"self-closing":t[6]?"closed":"single",new wp.shortcode({tag:t[2],attrs:t[3],type:e,content:t[5]})}},wp.shortcode=_.extend(function(t){_.extend(this,_.pick(t||{},"tag","attrs","type","content"));var e=this.attrs;this.attrs={named:{},numeric:[]},e&&(_.isString(e)?this.attrs=wp.shortcode.attrs(e):_.isEqual(_.keys(e),["named","numeric"])?this.attrs=e:_.each(t.attrs,function(t,e){this.set(e,t)},this))},wp.shortcode),_.extend(wp.shortcode.prototype,{get:function(t){return this.attrs[_.isNumber(t)?"numeric":"named"][t]},set:function(t,e){return this.attrs[_.isNumber(t)?"numeric":"named"][t]=e,this},string:function(){var n="["+this.tag;return _.each(this.attrs.numeric,function(t){/\s/.test(t)?n+=' "'+t+'"':n+=" "+t}),_.each(this.attrs.named,function(t,e){n+=" "+e+'="'+t+'"'}),"single"===this.type?n+"]":"self-closing"===this.type?n+" /]":(n+="]",this.content&&(n+=this.content),n+"[/"+this.tag+"]")}}),wp.html=_.extend(wp.html||{},{attrs:function(t){var e,n;return"/"===t[t.length-1]&&(t=t.slice(0,-1)),e=wp.shortcode.attrs(t),n=e.named,_.each(e.numeric,function(t){/\s/.test(t)||(n[t]="")}),n},string:function(t){var n="<"+t.tag,e=t.content||"";return _.each(t.attrs,function(t,e){n+=" "+e,_.isBoolean(t)&&(t=t?"true":"false"),n+='="'+t+'"'}),t.single?n+" />":(n+=">",(n+=_.isObject(e)?wp.html.string(e):e)+"</"+t.tag+">")}});