Skip to content

Fully integrated Sublime 3.1 syntax changes. #140

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

Merged
merged 4 commits into from
May 9, 2018

Conversation

Thom1729
Copy link
Contributor

@Thom1729 Thom1729 commented May 8, 2018

Updates the HTML.yaml base syntax to the latest version from core. The core syntax has been updated substantially since 3.0.

The most noteworthy change is a new way of parsing <script> and <style> type attributes. The old way (which this package extended) was based on regexp lookaheads, and it was not very reliable. The new way is much more robust, and this PR uses the new approach for the lang attribute of <script>, <style>, and <template> tags. To implement the new approach in this PR, I offloaded most of the boilerplate to a new macro.

Hopefully, this should solve any remaining problems with language detection.

Example of code that should now be correctly highlighted:

<script
lang
=
coffee
>
module.exports =
  data: ->
    msg: 'Hello from coffee!'
</script>

@yyx990803 yyx990803 requested a review from skyronic May 8, 2018 21:13
@Thom1729
Copy link
Contributor Author

Thom1729 commented May 8, 2018

I've undone #124 now that the Sublime bug it was intended for has been fixed. As of this PR, with_prototype is not used at all.

@skyronic
Copy link
Collaborator

skyronic commented May 9, 2018

@Thom1729 this seems to work really well, thank you for a pretty comprehensive and much cleaner implementation.

From testing it with Sublime 3.1, everything worked fine. However, when I compiled the syntax with yaml macros, I got a diff in the output syntax file

diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax
index d412a0d..a2448a8 100644
--- a/Vue Component.sublime-syntax	
+++ b/Vue Component.sublime-syntax	
@@ -708,7 +708,7 @@ contexts:
               scope: punctuation.definition.tag.end.html
               set:
                 - include: style-close-tag
-                - match: (?=\S)
+                - match: ''
                   embed_scope: source.sass.embedded.html
                   embed: scope:source.sass
                   escape: (?i)(?=(?:-->\s*)?</style)
@@ -722,7 +722,7 @@ contexts:
               scope: punctuation.definition.tag.end.html
               set:
                 - include: style-close-tag
-                - match: (?=\S)
+                - match: ''
                   embed_scope: source.scss.embedded.html
                   embed: scope:source.scss
                   escape: (?i)(?=(?:-->\s*)?</style)
@@ -736,7 +736,7 @@ contexts:
               scope: punctuation.definition.tag.end.html
               set:
                 - include: style-close-tag
-                - match: (?=\S)
+                - match: ''
                   embed_scope: source.stylus.embedded.html
                   embed: scope:source.stylus
                   escape: (?i)(?=(?:-->\s*)?</style)


(snipped for brevity)

No other file has been changed. I'm using YAML Macros 3.0.4. Please do clarify the exact behaviour and aside from this looked good to me. I'll check a few more things

One nice thing to note is that the new HTML implementation seems to have fixed #134 as well.

@Thom1729
Copy link
Contributor Author

Thom1729 commented May 9, 2018

That change should have been checked in. I'll recompile it and commit tomorrow morning.

@Thom1729
Copy link
Contributor Author

Thom1729 commented May 9, 2018

I've fixed the problem. The root cause was an issue with dynamically reloading macros, which I'm looking into a fix for.

@skyronic
Copy link
Collaborator

skyronic commented May 9, 2018

The root cause was an issue with dynamically reloading macros, which I'm looking into a fix for

That doesn't affect this pull request right? It should be an issue with the yaml Macros.

@skyronic
Copy link
Collaborator

skyronic commented May 9, 2018

@yyx990803 I can confirm that everything seems to work as expected, and there's no issue I could see in the code at this time. You can tag a new release from the new branch.

@Thom1729 Thanks again! Merging the PR now.

@skyronic skyronic merged commit 9950e5e into vuejs:new May 9, 2018
@Thom1729 Thom1729 deleted the sublime-3.1-improvements branch May 9, 2018 22:11
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.

2 participants