Skip to content

Commit

Permalink
Merge pull request #6 from 8fold/minify
Browse files Browse the repository at this point in the history
fix it for real
  • Loading branch information
joshbruce authored Nov 4, 2021
2 parents 1e6f274 + f2145d0 commit 2fbaf73
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function convert(string $markdown = ''): string
$markdown = $this->getBody($markdown);
$html = parent::convertToHtml($markdown)->getContent();

if ($this->minified and strpos("<pre><code>", $html) === false) {
if ($this->minified and ! str_contains($html, '<pre><code>')) {
return str_replace([
"\t",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion tests/FluentCommonMarkBaselineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 24 additions & 0 deletions tests/MarkdownBaselineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,27 @@
html
);
})->group('markdown');

test('Minify with code block', function() {
expect(
Markdown::create()->minified()->convert(<<<md
```
this is a code block
with multiple lines
it should not be minified
```
md
)
)->toBe(<<<html
<pre><code>this is a code block
with multiple lines
it should not be minified
</code></pre>
html
);
});

0 comments on commit 2fbaf73

Please sign in to comment.