Fix pasted HTML being detected as MJML #15
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the plugin's
.tmLanguage
contains afirstLineMatch
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 thisfirstLineMatch
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:
and
and
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).