Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pasted HTML being detected as MJML #15

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

ExplodingCabbage
Copy link
Contributor

@ExplodingCabbage ExplodingCabbage commented Feb 16, 2022

Currently, the plugin's .tmLanguage contains a firstLineMatch expression that matches any <!doctype ...> tag, <mjml> tag, or <?php tag. This doesn't make much sense, since MJML documents start with an <mjml> tag, not either of the other two, which indicate the start of a XML/HTML or PHP file respectively. Having this firstLineMatch value caused pasting a HTML document into a new file in Sublime to automatically enable the MJML syntax highlighting instead of the HTML syntax highlighting.

This change fixes the regex so that it will only match <mjml> tags, not tags associated with other languages.

Resolves #13

To test this, I cloned the package to my local Packages folder (i.e. the alternate installation flow described in this package's docs) and tried pasting the following snippets of code into new tabs in Sublime:

<!doctype html>

test test

and

<?php

echo "test test"

and

<mjml>
  <mj-body>
  </mj-body>
</mjml>

Before I made this change, pasting either the HTML snippet or the MJML snippets caused Sublime to select MJML syntax highlighting. After I made this change, all three snippets trigger the correct syntax highlighting (i.e. HTML, PHP, and MJML respectively).

Currently, the plugin's `.tmLanguage` contains a `firstLineMatch` expression that matches any `<!doctype ...>` tag, `<mjml>` tag, or `<!php` tag. This doesn't make much sense, since MJML documents start with an `<mjml>` tag, and caused pasting a HTML document into a new file in Sublime to automatically enable the MJML syntax highlighting instead of the HTML syntax highlighting.

This change fixes the regex so that it will only match `<mjml>` tags, not tags associated with other languages.

Resolves mjmlio#13

To test this, I cloned the package to my local Packages folder (i.e. the alternate installation flow described in this package's docs) and tried pasting the following snippets of code into new tabs in Sublime:

```
<!doctype html>

test test
```

and

```
<?php

echo "test test"
```

and

```
<mjml>
  <mj-body>
  </mj-body>
</mjml>
```

Before I made this change, pasting either the HTML snippet or the MJML snippets caused Sublime to select MJML syntax highlighting. After I made this change, all three snippets trigger the correct syntax highlighting (i.e. HTML, PHP, and MJML respectively).
@ExplodingCabbage
Copy link
Contributor Author

@ngarnier I'm not sure if you're maintaining this repo any more, but if you are, it'd be great if you could review this one-line fix and roll it out. :)

@iRyusa
Copy link
Member

iRyusa commented Mar 10, 2022

Dunno why I didn't get the notif on that D: Sorry, I'll see if I can find how to release it tho

@iRyusa iRyusa merged commit 40e4408 into mjmlio:master Mar 10, 2022
@ExplodingCabbage ExplodingCabbage deleted the fix-syntax-autodetection branch March 10, 2022 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sublime chooses MJML syntax when doing HTML
2 participants