upgrade HyperDown

This commit is contained in:
joyqi
2020-11-19 17:03:00 +08:00
parent 269832aa85
commit cee119eb4d
16 changed files with 83 additions and 58 deletions

View File

@@ -1 +1 @@
!function(e,l){var m,s,t=e.html5||{},r=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,c=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,n="_html5shiv",a=0,o={};function h(){var e=f.elements;return"string"==typeof e?e.split(" "):e}function u(e){var t=o[e[n]];return t||(t={},a++,e[n]=a,o[a]=t),t}function d(e,t,n){return t=t||l,s?t.createElement(e):(a=(n=n||u(t)).cache[e]?n.cache[e].cloneNode():c.test(e)?(n.cache[e]=n.createElem(e)).cloneNode():n.createElem(e)).canHaveChildren&&!r.test(e)?n.frag.appendChild(a):a;var a}function i(e){var t,n,a,r,c,o,i=u(e=e||l);return!f.shivCSS||m||i.hasCSS||(i.hasCSS=(n="article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}",a=(t=e).createElement("p"),r=t.getElementsByTagName("head")[0]||t.documentElement,a.innerHTML="x<style>"+n+"</style>",!!r.insertBefore(a.lastChild,r.firstChild))),s||(c=e,(o=i).cache||(o.cache={},o.createElem=c.createElement,o.createFrag=c.createDocumentFragment,o.frag=o.createFrag()),c.createElement=function(e){return f.shivMethods?d(e,c,o):o.createElem(e)},c.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+h().join().replace(/[\w\-]+/g,function(e){return o.createElem(e),o.frag.createElement(e),'c("'+e+'")'})+");return n}")(f,o.frag)),e}!function(){try{var e=l.createElement("a");e.innerHTML="<xyz></xyz>",m="hidden"in e,s=1==e.childNodes.length||function(){l.createElement("a");var e=l.createDocumentFragment();return void 0===e.cloneNode||void 0===e.createDocumentFragment||void 0===e.createElement}()}catch(e){s=m=!0}}();var f={elements:t.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==t.shivCSS,supportsUnknownElements:s,shivMethods:!1!==t.shivMethods,type:"default",shivDocument:i,createElement:d,createDocumentFragment:function(e,t){if(e=e||l,s)return e.createDocumentFragment();for(var n=(t=t||u(e)).frag.cloneNode(),a=0,r=h(),c=r.length;a<c;a++)n.createElement(r[a]);return n}};e.html5=f,i(l)}(this,document);
!function(e,i){var l,m,t=e.html5||{},a=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,n="_html5shiv",c=0,o={};function s(){var e=f.elements;return"string"==typeof e?e.split(" "):e}function h(e){var t=o[e[n]];return t||(t={},c++,e[n]=c,o[c]=t),t}function u(e,t,n){return t=t||i,m?t.createElement(e):(t=(n=n||h(t)).cache[e]?n.cache[e].cloneNode():r.test(e)?(n.cache[e]=n.createElem(e)).cloneNode():n.createElem(e)).canHaveChildren&&!a.test(e)?n.frag.appendChild(t):t}function d(e){var t,n,a,r,c,o=h(e=e||i);return!f.shivCSS||l||o.hasCSS||(o.hasCSS=(n="article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}",a=(t=e).createElement("p"),t=t.getElementsByTagName("head")[0]||t.documentElement,a.innerHTML="x<style>"+n+"</style>",!!t.insertBefore(a.lastChild,t.firstChild))),m||(r=e,(c=o).cache||(c.cache={},c.createElem=r.createElement,c.createFrag=r.createDocumentFragment,c.frag=c.createFrag()),r.createElement=function(e){return f.shivMethods?u(e,r,c):c.createElem(e)},r.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+s().join().replace(/[\w\-]+/g,function(e){return c.createElem(e),c.frag.createElement(e),'c("'+e+'")'})+");return n}")(f,c.frag)),e}!function(){try{var e=i.createElement("a");e.innerHTML="<xyz></xyz>",l="hidden"in e,m=1==e.childNodes.length||function(){i.createElement("a");var e=i.createDocumentFragment();return void 0===e.cloneNode||void 0===e.createDocumentFragment||void 0===e.createElement}()}catch(e){m=l=!0}}();var f={elements:t.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==t.shivCSS,supportsUnknownElements:m,shivMethods:!1!==t.shivMethods,type:"default",shivDocument:d,createElement:u,createDocumentFragment:function(e,t){if(e=e||i,m)return e.createDocumentFragment();for(var n=(t=t||h(e)).frag.cloneNode(),a=0,r=s(),c=r.length;a<c;a++)n.createElement(r[a]);return n}};e.html5=f,d(i)}(this,document);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
admin/js/jquery.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
!function(e){"use strict";var t,n,a,s,i,r;e.matchMedia=e.matchMedia||(t=e.document,a=t.documentElement,s=a.firstElementChild||a.firstChild,i=t.createElement("body"),(r=t.createElement("div")).id="mq-test-1",r.style.cssText="position:absolute;top:-100em",i.style.background="none",i.appendChild(r),function(e){return r.innerHTML='&shy;<style media="'+e+'"> #mq-test-1 { width: 42px; }</style>',a.insertBefore(i,s),n=42===r.offsetWidth,a.removeChild(i),{matches:n,media:e}})}(this),function(y){"use strict";var c={};(y.respond=c).update=function(){};function e(e,t){var n=a();n&&(n.open("GET",e,!0),n.onreadystatechange=function(){4!==n.readyState||200!==n.status&&304!==n.status||t(n.responseText)},4!==n.readyState&&n.send(null))}function p(e){return e.replace(c.regex.minmaxwh,"").match(c.regex.other)}var x,v,E,w,S,i,T,r,C,b,$,z,M,R,o,l,t,m=[],a=function(){var t=!1;try{t=new y.XMLHttpRequest}catch(e){t=new y.ActiveXObject("Microsoft.XMLHTTP")}return function(){return t}}();function n(){R(!0)}c.ajax=e,c.queue=m,c.unsupportedmq=p,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=y.matchMedia&&null!==y.matchMedia("only all")&&y.matchMedia("only all").matches,c.mediaQueriesSupported||(x=y.document,v=x.documentElement,E=[],w=[],S=[],i={},T=x.getElementsByTagName("head")[0]||v,r=x.getElementsByTagName("base")[0],C=T.getElementsByTagName("link"),M=function(){var e,t=x.createElement("div"),n=x.body,a=v.style.fontSize,s=n&&n.style.fontSize,i=!1;return t.style.cssText="position:absolute;font-size:1em;width:1em",n||((n=i=x.createElement("body")).style.background="none"),v.style.fontSize="100%",n.style.fontSize="100%",n.appendChild(t),i&&v.insertBefore(n,v.firstChild),e=t.offsetWidth,i?v.removeChild(n):n.removeChild(t),v.style.fontSize=a,s&&(n.style.fontSize=s),e=z=parseFloat(e)},R=function(e){var t,n,a,s,i,r,o,l="clientWidth",m=v[l],d="CSS1Compat"===x.compatMode&&m||x.body[l]||m,h={},u=C[C.length-1],c=(new Date).getTime();if(e&&b&&c-b<30)return y.clearTimeout($),void($=y.setTimeout(R,30));for(var p in b=c,E){E.hasOwnProperty(p)&&(n=null===(s=(t=E[p]).minw),a=null===(i=t.maxw),s=s&&parseFloat(s)*(-1<s.indexOf("em")?z||M():1),i=i&&parseFloat(i)*(-1<i.indexOf("em")?z||M():1),t.hasquery&&(n&&a||!(n||s<=d)||!(a||d<=i))||(h[t.media]||(h[t.media]=[]),h[t.media].push(w[t.rules])))}for(var f in S)S.hasOwnProperty(f)&&S[f]&&S[f].parentNode===T&&T.removeChild(S[f]);for(var g in S.length=0,h){h.hasOwnProperty(g)&&(r=x.createElement("style"),o=h[g].join("\n"),r.type="text/css",r.media=g,T.insertBefore(r,u.nextSibling),r.styleSheet?r.styleSheet.cssText=o:r.appendChild(x.createTextNode(o)),S.push(r))}},o=function(e,t,n){function a(e){return e.replace(c.regex.urls,"$1"+t+"$2$3")}var s=e.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),i=s&&s.length||0,r=!i&&n;(t=t.substring(0,t.lastIndexOf("/"))).length&&(t+="/"),r&&(i=1);for(var o,l,m,d,h=0;h<i;h++){r?(o=n,w.push(a(e))):(o=s[h].match(c.regex.findStyles)&&RegExp.$1,w.push(RegExp.$2&&a(RegExp.$2))),d=(m=o.split(",")).length;for(var u=0;u<d;u++)l=m[u],p(l)||E.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:w.length-1,hasquery:-1<l.indexOf("("),minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}R()},l=function(){var t;m.length&&(t=m.shift(),e(t.href,function(e){o(e,t.href,t.media),i[t.href]=!0,y.setTimeout(function(){l()},0)}))},(t=function(){for(var e=0;e<C.length;e++){var t=C[e],n=t.href,a=t.media,s=t.rel&&"stylesheet"===t.rel.toLowerCase();n&&s&&!i[n]&&(t.styleSheet&&t.styleSheet.rawCssText?(o(t.styleSheet.rawCssText,n,a),i[n]=!0):(/^([a-zA-Z:]*\/\/)/.test(n)||r)&&n.replace(RegExp.$1,"").split("/")[0]!==y.location.host||("//"===n.substring(0,2)&&(n=y.location.protocol+n),m.push({href:n,media:a})))}l()})(),c.update=t,c.getEmValue=M,y.addEventListener?y.addEventListener("resize",n,!1):y.attachEvent&&y.attachEvent("onresize",n))}(this);
!function(e){"use strict";var t,n,s,a,i;e.matchMedia=e.matchMedia||(e=e.document,n=e.documentElement,s=n.firstElementChild||n.firstChild,a=e.createElement("body"),(i=e.createElement("div")).id="mq-test-1",i.style.cssText="position:absolute;top:-100em",a.style.background="none",a.appendChild(i),function(e){return i.innerHTML='&shy;<style media="'+e+'"> #mq-test-1 { width: 42px; }</style>',n.insertBefore(a,s),t=42===i.offsetWidth,n.removeChild(a),{matches:t,media:e}})}(this),function(g){"use strict";var c={};(g.respond=c).update=function(){};function e(e,t){var n=s();n&&(n.open("GET",e,!0),n.onreadystatechange=function(){4!==n.readyState||200!==n.status&&304!==n.status||t(n.responseText)},4!==n.readyState&&n.send(null))}function p(e){return e.replace(c.regex.minmaxwh,"").match(c.regex.other)}var y,x,E,v,w,i,S,r,T,C,b,$,z,M,o,l,t,m=[],s=function(){var t=!1;try{t=new g.XMLHttpRequest}catch(e){t=new g.ActiveXObject("Microsoft.XMLHTTP")}return function(){return t}}();function n(){M(!0)}c.ajax=e,c.queue=m,c.unsupportedmq=p,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=g.matchMedia&&null!==g.matchMedia("only all")&&g.matchMedia("only all").matches,c.mediaQueriesSupported||(y=g.document,x=y.documentElement,E=[],v=[],w=[],i={},S=y.getElementsByTagName("head")[0]||x,r=y.getElementsByTagName("base")[0],T=S.getElementsByTagName("link"),z=function(){var e,t=y.createElement("div"),n=y.body,s=x.style.fontSize,a=n&&n.style.fontSize,i=!1;return t.style.cssText="position:absolute;font-size:1em;width:1em",n||((n=i=y.createElement("body")).style.background="none"),x.style.fontSize="100%",n.style.fontSize="100%",n.appendChild(t),i&&x.insertBefore(n,x.firstChild),e=t.offsetWidth,i?x.removeChild(n):n.removeChild(t),x.style.fontSize=s,a&&(n.style.fontSize=a),$=parseFloat(e)},M=function(e){var t,n,s,a,i,r,o,l,m,d,h="clientWidth",u=x[h],c="CSS1Compat"===y.compatMode&&u||y.body[h]||u,p={},f=T[T.length-1],u=(new Date).getTime();if(e&&C&&u-C<30)return g.clearTimeout(b),void(b=g.setTimeout(M,30));for(t in C=u,E)E.hasOwnProperty(t)&&(s=null===(i=(n=E[t]).minw),a=null===(r=n.maxw),i=i&&parseFloat(i)*(-1<i.indexOf("em")?$||z():1),r=r&&parseFloat(r)*(-1<r.indexOf("em")?$||z():1),n.hasquery&&(s&&a||!(s||i<=c)||!(a||c<=r))||(p[n.media]||(p[n.media]=[]),p[n.media].push(v[n.rules])));for(o in w)w.hasOwnProperty(o)&&w[o]&&w[o].parentNode===S&&S.removeChild(w[o]);for(l in w.length=0,p)p.hasOwnProperty(l)&&(m=y.createElement("style"),d=p[l].join("\n"),m.type="text/css",m.media=l,S.insertBefore(m,f.nextSibling),m.styleSheet?m.styleSheet.cssText=d:m.appendChild(y.createTextNode(d)),w.push(m))},o=function(e,t,n){function s(e){return e.replace(c.regex.urls,"$1"+t+"$2$3")}var a=e.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),i=a&&a.length||0,r=!i&&n;(t=t.substring(0,t.lastIndexOf("/"))).length&&(t+="/"),r&&(i=1);for(var o,l,m,d,h=0;h<i;h++){r?(o=n,v.push(s(e))):(o=a[h].match(c.regex.findStyles)&&RegExp.$1,v.push(RegExp.$2&&s(RegExp.$2))),d=(m=o.split(",")).length;for(var u=0;u<d;u++)l=m[u],p(l)||E.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:v.length-1,hasquery:-1<l.indexOf("("),minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}M()},l=function(){var t;m.length&&(t=m.shift(),e(t.href,function(e){o(e,t.href,t.media),i[t.href]=!0,g.setTimeout(function(){l()},0)}))},(t=function(){for(var e=0;e<T.length;e++){var t=T[e],n=t.href,s=t.media,a=t.rel&&"stylesheet"===t.rel.toLowerCase();n&&a&&!i[n]&&(t.styleSheet&&t.styleSheet.rawCssText?(o(t.styleSheet.rawCssText,n,s),i[n]=!0):(/^([a-zA-Z:]*\/\/)/.test(n)||r)&&n.replace(RegExp.$1,"").split("/")[0]!==g.location.host||("//"===n.substring(0,2)&&(n=g.location.protocol+n),m.push({href:n,media:s})))}l()})(),c.update=t,c.getEmValue=z,g.addEventListener?g.addEventListener("resize",n,!1):g.attachEvent&&g.attachEvent("onresize",n))}(this);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -291,7 +291,7 @@
};
Parser.prototype.parseInline = function(text, whiteList, clearHolders, enableAutoLink) {
var regex;
var parseBackSlash, regex;
if (whiteList == null) {
whiteList = '';
}
@@ -301,7 +301,20 @@
if (enableAutoLink == null) {
enableAutoLink = true;
}
parseBackSlash = (function(_this) {
return function(text) {
return text.replace(/\\{1,}/g, function(str) {
return str.length % 2 > 0 && '' + str + '\\' || str;
});
};
})(this);
text = this.call('beforeParseInline', text);
text = String.raw`` + text + '';
text = text.split(/(`.+?`)/g).reduce(function(str, cur) {
str = str || '';
cur = cur || '';
return ((str.match(/`.+?`/g)) && str || parseBackSlash(str)) + ((cur.match(/`.+?`/g)) && cur || parseBackSlash(cur));
});
text = text.replace(/(^|[^\\])(`+)(.+?)\2/mg, (function(_this) {
return function() {
var matches;
@@ -341,7 +354,7 @@
if (_this.html || (('|' + _this.commonWhiteList + '|' + whiteList + '|').indexOf('|' + matches[2].toLowerCase() + '|')) >= 0) {
return _this.makeHolder(matches[0]);
} else {
return htmlspecialchars(matches[0]);
return _this.makeHolder(htmlspecialchars(matches[0]));
}
};
})(this));
@@ -520,16 +533,7 @@
Parser.prototype.parseBlockList = function(block, key, line, state) {
var matches, space;
if (!!(matches = line.match(/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i))) {
space = matches[1].length;
state.empty = 0;
if (this.isBlock('list')) {
this.setBlock(key, space);
} else {
this.startBlock('list', key, space);
}
return false;
} else if ((this.isBlock('list')) && !line.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/)) {
if ((this.isBlock('list')) && !line.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/)) {
if ((state.empty <= 1) && !!(matches = line.match(/^(\s+)/)) && matches[1].length > block[3]) {
state.empty = 0;
this.setBlock(key);
@@ -540,6 +544,16 @@
return false;
}
}
if (!!(matches = line.match(/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i))) {
space = matches[1].length;
state.empty = 0;
if (this.isBlock('list')) {
this.setBlock(key, space);
} else {
this.startBlock('list', key, space);
}
return false;
}
return true;
};
@@ -1162,7 +1176,7 @@
Parser.prototype.cleanUrl = function(url) {
var matches, regexUrl, regexWord;
regexUrl = new RegExp("^\\s*((http|https|ftp|mailto):[" + pL + "_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&\\(\\)]+)", 'i');
regexUrl = new RegExp("^\\s*((http|https|ftp|mailto):[" + pL + "_a-z0-9-:\\.\\*/%#;!@\\?\\+=~\\|\\,&\\(\\)]+)", 'i');
regexWord = new RegExp("^\\s*([" + pL + "_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&]+)", 'i');
if (!!(matches = url.match(regexUrl))) {
return matches[1];

View File

@@ -3155,9 +3155,9 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"uglify-js": {
"version": "3.11.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.1.tgz",
"integrity": "sha512-OApPSuJcxcnewwjSGGfWOjx3oix5XpmrK9Z2j0fTRlHGoZ49IU6kExfZTM0++fCArOOCet+vIfWwFHbvWqwp6g=="
"version": "3.11.6",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.6.tgz",
"integrity": "sha512-oASI1FOJ7BBFkSCNDZ446EgkSuHkOZBuqRFrwXIKWCoXw8ZXQETooTQjkAcBS03Acab7ubCKsXnwuV2svy061g=="
},
"unbzip2-stream": {
"version": "1.4.3",

View File

@@ -4,8 +4,8 @@
"description": "Typecho build tools",
"main": "build.js",
"scripts": {
"build_js": "node build.js js",
"build_css": "node build.js css"
"build_js": "node build.js js",
"build_css": "node build.js css"
},
"keywords": [
"typecho"
@@ -16,6 +16,6 @@
"chalk": "^4.0.0",
"node-sass": "^4.14.1",
"sprite-magic-importer": "^1.6.2",
"uglify-js": "^3.9.3"
"uglify-js": "^3.11.6"
}
}

View File

@@ -265,7 +265,7 @@ class HyperDown
$result = $this->call('after' . ucfirst($method), $result, $value);
$html .= $result;
}
}
return $html;
}
@@ -378,15 +378,24 @@ class HyperDown
public function parseInline($text, $whiteList = '', $clearHolders = true, $enableAutoLink = true)
{
$self = $this;
$text = $this->call('beforeParseInline', $text);
$text = $this->call('beforeParseInline', $text);
$text = preg_replace_callback("/\\\+/",function($matches) {
$str = $matches[0];
if(mb_strlen($str) % 2>0) {
return $str . '\\';
} else {
return $str;
}
},$text);
// code
$text = preg_replace_callback(
"/(^|[^\\\])(`+)(.+?)\\2/",
function ($matches) use ($self) {
return $matches[1] . $self->makeHolder(
'<code>' . htmlspecialchars($matches[3]) . '</code>'
);
'<code>' . htmlspecialchars($matches[3]) . '</code>'
);
},
$text
);
@@ -396,8 +405,8 @@ class HyperDown
"/(^|[^\\\])(\\$+)(.+?)\\2/",
function ($matches) use ($self) {
return $matches[1] . $self->makeHolder(
$matches[2] . htmlspecialchars($matches[3]) . $matches[2]
);
$matches[2] . htmlspecialchars($matches[3]) . $matches[2]
);
},
$text
);
@@ -432,11 +441,11 @@ class HyperDown
"/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/i",
function ($matches) use ($self, $whiteList) {
if ($self->_html || false !== stripos(
'|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
)) {
'|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
)) {
return $self->makeHolder($matches[0]);
} else {
return htmlspecialchars($matches[0]);
return $self->makeHolder(htmlspecialchars($matches[0]));
}
},
$text
@@ -523,7 +532,7 @@ class HyperDown
return $self->makeHolder($result);
},
$text
);
);
// strong and em and some fuck
$text = $this->parseInlineCallback($text);
@@ -647,7 +656,7 @@ class HyperDown
$this->_blocks = array();
$this->_current = 'normal';
$this->_pos = -1;
$state = array(
'special' => implode("|", array_keys($this->_specialWhiteList)),
'empty' => 0,
@@ -690,19 +699,7 @@ class HyperDown
*/
private function parseBlockList($block, $key, $line, &$state)
{
if (preg_match("/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i", $line, $matches)) {
$space = strlen($matches[1]);
$state['empty'] = 0;
// opened
if ($this->isBlock('list')) {
$this->setBlock($key, $space);
} else {
$this->startBlock('list', $key, $space);
}
return false;
} else if ($this->isBlock('list') && !preg_match("/^\s*\[((?:[^\]]|\\]|\\[)+?)\]:\s*(.+)$/", $line)) {
if ($this->isBlock('list') && !preg_match("/^\s*\[((?:[^\]]|\\]|\\[)+?)\]:\s*(.+)$/", $line)) {
if ($state['empty'] <= 1
&& preg_match("/^(\s+)/", $line, $matches)
&& strlen($matches[1]) > $block[3]) {
@@ -717,6 +714,20 @@ class HyperDown
}
}
if (preg_match("/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i", $line, $matches)) {
$space = strlen($matches[1]);
$state['empty'] = 0;
// opened
if ($this->isBlock('list')) {
$this->setBlock($key, $space);
} else {
$this->startBlock('list', $key, $space);
}
return false;
}
return true;
}
@@ -1068,7 +1079,7 @@ class HyperDown
private function parseBlockMh($block, $key, $line, &$state, $lines)
{
if (preg_match("/^\s*((=|-){2,})\s*$/", $line, $matches)
&& ($block && $block[0] == "normal" && !preg_match("/^\s*$/", $lines[$block[2]]))) { // check if last line isn't empty
&& ($block && $block[0] == "normal" && !preg_match("/^\s*$/", $lines[$block[2]]))) { // check if last line isn't empty
if ($this->isBlock('normal')) {
$this->backBlock(1, 'mh', $matches[1][0] == '=' ? 1 : 2)
->setBlock($key)
@@ -1403,7 +1414,7 @@ class HyperDown
if (preg_match("/^(\s*)/", $line, $matches)) {
$space = strlen($matches[1]);
if ($space > 0) {
$secondMinSpace = min($space, $secondMinSpace);
$secondFound = true;
@@ -1649,7 +1660,7 @@ class HyperDown
*/
public function cleanUrl($url)
{
if (preg_match("/^\s*((http|https|ftp|mailto):[\p{L}_a-z0-9-:\.\*\/%#!@\?\+=~\|\,&\(\)]+)/iu", $url, $matches)) {
if (preg_match("/^\s*((http|https|ftp|mailto):[\p{L}_a-z0-9-:\.\*\/%#;!@\?\+=~\|\,&\(\)]+)/iu", $url, $matches)) {
return $matches[1];
} else if (preg_match("/^\s*([\p{L}_a-z0-9-:\.\*\/%#!@\?\+=~\|\,&]+)/iu", $url, $matches)) {
return $matches[1];