From f2145d0d88f75d343a200531a4b960a27cca93d2 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Wed, 3 Nov 2021 19:51:00 -0500 Subject: [PATCH] fix it for real --- src/Markdown.php | 2 +- tests/FluentCommonMarkBaselineTest.php | 2 +- tests/MarkdownBaselineTest.php | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Markdown.php b/src/Markdown.php index 6cc0fcd..cb3a388 100644 --- a/src/Markdown.php +++ b/src/Markdown.php @@ -58,7 +58,7 @@ public function convert(string $markdown = ''): string $markdown = $this->getBody($markdown); $html = parent::convertToHtml($markdown)->getContent(); - if ($this->minified and strpos("
", $html) === false) {
+        if ($this->minified and ! str_contains($html, '
')) {
             return str_replace([
                 "\t",
                 "\n",
diff --git a/tests/FluentCommonMarkBaselineTest.php b/tests/FluentCommonMarkBaselineTest.php
index 1a62676..e21f5ab 100644
--- a/tests/FluentCommonMarkBaselineTest.php
+++ b/tests/FluentCommonMarkBaselineTest.php
@@ -28,7 +28,7 @@
     $elapsed = $endMs - $startMs;
     $ms      = $elapsed/1e+6;
 
-    expect($ms)->toBeLessThan(26.53);
+    expect($ms)->toBeLessThan(34);
 
     $used = $endMem - $startMem;
     $kb   = round($used/1024.2);
diff --git a/tests/MarkdownBaselineTest.php b/tests/MarkdownBaselineTest.php
index 1f022a3..d7450e5 100644
--- a/tests/MarkdownBaselineTest.php
+++ b/tests/MarkdownBaselineTest.php
@@ -64,3 +64,27 @@
         html
     );
 })->group('markdown');
+
+test('Minify with code block', function() {
+    expect(
+        Markdown::create()->minified()->convert(<<toBe(<<this is a code block
+
+        with multiple lines
+
+        it should not be minified
+        
+ + html + ); +});