test inlining

This commit is contained in:
Bruno Rybársky 2024-02-04 10:30:39 +01:00
parent 3c21c5e2f8
commit 76cafbda3a

@ -1,7 +1,7 @@
<?php <?php
function inlineLocalStylesFromHref($inputString) { function inlineLocalStylesFromHref($inputString) {
// Define the regular expression pattern to match <link> tags with href attribute for CSS files // Define the regular expression pattern to match <link> tags with href attribute for CSS files
$pattern = '/<link.*?(?:href=["\']\/(.*?)["\'].*?rel=["\']stylesheet["\']|rel=["\']stylesheet["\'].*?href=["\']\/(.*?)["\']).*?>/i'; $pattern = '/<link.*?(?:(?:rel=["\']stylesheet["\'].*?href=["\']\/(.*?)["\'])|(?:href=["\']\/(.*?)["\'].*?rel=["\']stylesheet["\'])).*?>/i';
// Use preg_replace_callback to replace matched link tags with inline styles // Use preg_replace_callback to replace matched link tags with inline styles
$outputString = preg_replace_callback($pattern, function($match) { $outputString = preg_replace_callback($pattern, function($match) {
@ -20,6 +20,7 @@ function inlineLocalStylesFromHref($inputString) {
return $outputString; return $outputString;
} }
function inlineScriptFromSrc($inputString) { function inlineScriptFromSrc($inputString) {
// Define the regular expression pattern to match <script> tags with src attribute // Define the regular expression pattern to match <script> tags with src attribute
$pattern = '/<script.*?src=["\']\/(.*?)["\'].*?>\s*<\/script>/i'; $pattern = '/<script.*?src=["\']\/(.*?)["\'].*?>\s*<\/script>/i';