Refine empty line handling without changing line numbers

This commit is contained in:
Kijin Sung 2023-09-05 00:42:12 +09:00
parent cd8e6371c6
commit fd27ec177b

View file

@ -327,8 +327,17 @@ class TemplateHandler
{ {
$buff = rtrim($buff) . PHP_EOL; $buff = rtrim($buff) . PHP_EOL;
} }
$buff = preg_replace('/\n[\t\x20]*?(?=\n)/', "\n<?php ?>", $buff); $buff = preg_replace([
$buff = preg_replace('/\n[\t\x20]+?\<\?php/', "\n<?php", $buff); '/>\<\?php } \?\>\n[\t\x20]*?(?=\n<!--)/',
'/\n[\t\x20]*?(?=\n<!--)/',
'/\n[\t\x20]*?(?=\n)/',
'/\n[\t\x20]+?\<\?php/',
], [
"><?php } ?>\n<?php echo \"\\n\"; ?>",
"\n",
"\n<?php ?>",
"\n<?php",
], $buff);
// restore config to previous value // restore config to previous value
$this->config = $previous_config; $this->config = $previous_config;