diff --git a/src/Mjml.php b/src/Mjml.php
index 0d4a32c..1f498cc 100755
--- a/src/Mjml.php
+++ b/src/Mjml.php
@@ -138,6 +138,9 @@ public function convert(string $mjml, array $options = []): MjmlResult
? $this->getSideCarResult($arguments)
: $this->getLocalResult($arguments);
+
+ $resultString = $this->checkForDeprecationWarning($resultString);
+
$resultProperties = json_decode($resultString, true);
if (array_key_exists('mjmlError', $resultProperties)) {
@@ -147,6 +150,17 @@ public function convert(string $mjml, array $options = []): MjmlResult
return new MjmlResult($resultProperties);
}
+ protected function checkForDeprecationWarning(string $result): string
+ {
+ $deprecationWarning = 'MJML v3 syntax detected, migrating to MJML v4 syntax. Use mjml -m to get the migrated MJML.';
+
+ if (str_contains($result, $deprecationWarning)) {
+ $result = str_replace($deprecationWarning, '', $result);
+ }
+
+ return $result;
+ }
+
protected function getCommand(array $arguments): array
{
return [
diff --git a/tests/MjmlTest.php b/tests/MjmlTest.php
index 483740b..be6cd83 100644
--- a/tests/MjmlTest.php
+++ b/tests/MjmlTest.php
@@ -100,6 +100,14 @@
Mjml::new()->sidecar()->toHtml(mjmlSnippet());
})->throws(SidecarPackageUnavailable::class);
+it('can determine if the given mjml can be converted when the mjml is deprecated', function (string $mjml, bool $expectedResult) {
+ expect(Mjml::new()->canConvert($mjml))->toBe($expectedResult);
+})->with([
+ ['', true],
+ ['', false], // deprecated mjml
+ ['', true],
+]);
+
function mjmlSnippet(): string
{
return <<<'MJML'