Fixing new lines preserving for one line comments
Publish PHP Package / docker (push) Failing after 3s
Details
Publish PHP Package / docker (push) Failing after 3s
Details
This commit is contained in:
parent
a6f7839b0c
commit
20e06b8433
|
@ -254,9 +254,8 @@ class JSM
|
||||||
{
|
{
|
||||||
if(strpos($txt, '/*') === false)
|
if(strpos($txt, '/*') === false)
|
||||||
return $txt;
|
return $txt;
|
||||||
$regex = '~/\*.*?\*/~s';
|
|
||||||
$txt = preg_replace_callback(
|
$txt = preg_replace_callback(
|
||||||
$regex,
|
'~/\*.*?\*/~s',
|
||||||
//preserve the new lines for better error reporting
|
//preserve the new lines for better error reporting
|
||||||
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
||||||
$txt);
|
$txt);
|
||||||
|
@ -266,7 +265,11 @@ class JSM
|
||||||
private static function _removeLineComments(string $txt) : string
|
private static function _removeLineComments(string $txt) : string
|
||||||
{
|
{
|
||||||
//TODO: it's not robust enough, note a hack for URL addresses
|
//TODO: it's not robust enough, note a hack for URL addresses
|
||||||
$txt = preg_replace("~\s*(?<!:)//.*~", "\n", $txt);
|
$txt = preg_replace_callback(
|
||||||
|
'~\s*(?<!:)//.*~',
|
||||||
|
//preserve the new lines for better error reporting
|
||||||
|
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
||||||
|
$txt);
|
||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue