From f67c6a6186d553f11714d13205e91a107cc78d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sun, 4 Feb 2024 10:21:56 +0100 Subject: [PATCH] test inlining --- lib/inliner.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ lib/page.php | 3 +++ 2 files changed, 48 insertions(+) create mode 100644 lib/inliner.php diff --git a/lib/inliner.php b/lib/inliner.php new file mode 100644 index 0000000..5244b7d --- /dev/null +++ b/lib/inliner.php @@ -0,0 +1,45 @@ + tags with href attribute for CSS files + $pattern = '//i'; + + // Use preg_replace_callback to replace matched link tags with inline styles + $outputString = preg_replace_callback($pattern, function($match) use ($basePath) { + // Extract the href attribute value + $href = $match[1]; + + // Get the content of the local CSS file + $cssContent = file_get_contents($basePath . '/assets/' . $href); + + // Create an inline style tag with the CSS content + return ""; + }, $inputString); + + return $outputString; +} + +function inlineScriptFromSrc($inputString) { + $basePath = '/path/to/your/local/files'; // Hardcoded base path + + // Define the regular expression pattern to match "; + }, $inputString); + + return $outputString; +} \ No newline at end of file diff --git a/lib/page.php b/lib/page.php index 180a423..aa363c6 100644 --- a/lib/page.php +++ b/lib/page.php @@ -1,4 +1,5 @@