-
Notifications
You must be signed in to change notification settings - Fork 143
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
Embed rewriting not perfect #222
Comments
I guess the fundamental flaw with rewriting Simple example %YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
scope: source.embed-vs-with_prototype
contexts:
main:
- match: embed
scope: keyword.begin
embed: contents
escape: escape
escape_captures:
0: keyword.end
- match: with_prototype
scope: keyword.begin
push:
- [{ meta_include_prototype: false }, { match: escape, scope: keyword.end, pop: true }]
- contents
with_prototype:
- match: (?=escape)
pop: true
contents:
- match: \w+
scope: string Test text:
So unfortunately, I believe we will need to include native support for |
Makes sense! So escape needs to have precedence over other matches. |
Just a note for when we work on this, there is an open question for SublimeHQ to answer regarding whether the |
@keith-hall So let me get this straight, in this example:
So in that case, the escape match takes precedence and the match for I'm wondering how that's implemented (and how we would implement it). Does something like this make sense?:
What happens if there are multiple active embeds that has matching escapes, which one wins? |
yes, that makes sense, and sounds like the way forward. |
I tried this example:
With the input With |
nice 👍 one other thing I wanted to check was how escapes are handled if one escape pattern matches inside another one... say, |
Just tested, |
After the latest fixes, I tried updating the submodules, and can see we still have some syntax test failures, this time relating to
embed
...escape
:We get the same failures in Sublime Text, when rewriting the
embed
...escape
rules towith_prototype
likesyntect
'syaml_load
is doing, so the good news is thatsyntect
s parser is working correctly:JavaDoc.sublime-syntax
:Markdown.sublime-syntax
:For Java(Doc), the workaround suggested at #160 (comment) works.
For Markdown, the following syntax test is enough to see the problem:
Everything except the last line's assertions pass. Adding
?>
before the closing backticks/code fence allows the backticks to be correctly recognized as the closing code fence instead of PHP interpolated string punctuation, but we will need a solution so that the waysyntect
handlesembed
actions will work 100% correctly in all situations.Altering the
PHP Source
syntax definition can help to work around it, which (although obviously not a solution,) suggests that, for some reason, thewith_prototype
(rewritten from theembed
in the Markdown syntax definition) is not being considered at this point (in both Sublime andsyntect
):The text was updated successfully, but these errors were encountered: