Update common.php

Keep all line breaks in Readmemd / 保留Readmemd内容的全部换行
pull/360/head
zzjjbb 2021-06-21 11:55:02 -04:00 committed by GitHub
parent 74bb87ef15
commit 134709b6b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -2565,8 +2565,8 @@ function render_list($path = '', $files = [])
$html = $tmp[0]; $html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--ReadmemdEnd-->'); $tmp = splitfirst($tmp[1], '<!--ReadmemdEnd-->');
if (isset($files['list']['readme.md'])) { if (isset($files['list']['readme.md'])) {
$Readmemd = str_replace('<!--ReadmemdContent-->', get_content(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'], $tmp[0]); $Readmemd = get_content(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'];
$html .= $Readmemd . $tmp[1]; $html .= $tmp[0] . $tmp[1];
while (strpos($html, '<!--ReadmemdStart-->')) { while (strpos($html, '<!--ReadmemdStart-->')) {
$html = str_replace('<!--ReadmemdStart-->', '', $html); $html = str_replace('<!--ReadmemdStart-->', '', $html);
$html = str_replace('<!--ReadmemdEnd-->', '', $html); $html = str_replace('<!--ReadmemdEnd-->', '', $html);
@ -2671,6 +2671,9 @@ function render_list($path = '', $files = [])
//while (strpos($html, "\r\r")) $html = str_replace("\r\r", "\r", $html); //while (strpos($html, "\r\r")) $html = str_replace("\r\r", "\r", $html);
while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html); while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html);
//while (strpos($html, PHP_EOL.PHP_EOL)) $html = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $html); //while (strpos($html, PHP_EOL.PHP_EOL)) $html = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $html);
if (isset($Readmemd)) {
$html = str_replace('<!--ReadmemdContent-->', $Readmemd, $html);
} // 保留Readmemd的换行
$exetime = round(microtime(true)-$_SERVER['php_starttime'],3); $exetime = round(microtime(true)-$_SERVER['php_starttime'],3);
//$ip2city = json_decode(curl('GET', 'http://ip.taobao.com/outGetIpInfo?ip=' . $_SERVER['REMOTE_ADDR'] . '&accessKey=alibaba-inc')['body'], true); //$ip2city = json_decode(curl('GET', 'http://ip.taobao.com/outGetIpInfo?ip=' . $_SERVER['REMOTE_ADDR'] . '&accessKey=alibaba-inc')['body'], true);