From 2b4612493cf318aab0ff2e05a9f35e79745cb26f Mon Sep 17 00:00:00 2001 From: spirit Date: Mon, 28 Oct 2019 20:52:29 +0800 Subject: [PATCH] fix #119 --- functions.php | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/functions.php b/functions.php index afa99cf..ff613f9 100644 --- a/functions.php +++ b/functions.php @@ -1513,32 +1513,36 @@ function codecheese_register_post( $sanitized_user_login, $user_email, $errors ) // html 标签处理器 function html_tag_parser($content) { - if(!is_feed()) { - if(akina_option('lazyload') && akina_option('lazyload_spinner')){ - $content=preg_replace( - '//i', - "\n", - $content - ); - } + if(!is_feed()) { + $content=preg_replace( + '//i', + "\n", + $content + ); //Fancybox /* Markdown Regex Pattern for Matching URLs: * https://daringfireball.net/2010/07/improved_regex_for_matching_urls */ - $url_regex ='(((http|https):\/\/)?(\w(\:\w)?@)?([0-9a-z_-]+\.)*?([a-z0-9-]+\.[a-z]{2,6}(\.[a-z]{2})?(\:[0-9]{2,6})?)((\/[^?#<>\/\\*":]*)+(\?[^#]*)?(#.*)?)?)'; + $url_regex ='((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))'; //With Thumbnail: !{alt}(url)[th_url] - $content=preg_replace( - '/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i', - '', - $content - ); + if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){ + $i=0; + foreach ($matches as $val) { + $content=str_replace($val[$i],preg_replace( + '/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i', + '', + $val[$i]), + $content); + $i++; + } + } //Without Thumbnail :!{alt}(url) $content=preg_replace(