-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add Antlers support #124
Add Antlers support #124
Conversation
This happens because of how patterns and injections are parsed, the problem actually isn't in the comment injection or pattern, it's in The solution would be to keep the comment pattern and all patterns related to
I actually plan on merging #123 soon, so I guess you'll want to wait and apply patterns for those newly added tokens as well? Let me know if you need more help! You can also join our Discord to talk in real time :) |
FYI #123 has been merged :) |
Thanks for your answers! I'm already on the discord but I'm only opening Discord when someone needs me there. I will join the vocal channel when I reopen this PR. It may be only next week thought. Should I convert it as draft in the meantime ? |
Yes it ca be draft :) |
Hi @brendt 🙂, I tried with the suggested approach and resolved the comment issue but this came with a lot more complexity.
I'm sorry, It's difficult to explain with words, reading my tests including the ones that I commented should give you more insights. I think Antlers tag should be an injected language, same has Blade is injecting php in a blade directive. It's may be easier to find a way around the comment injection being prioritised 😅 Also, I feel like I've done something wrong by rebasing the PR. I would reopen a new PR if needed. |
Makes sense 👍
Gotcha. Blade is different in that most tags are written with
As something more like this?
|
Unfortunately not, it's slightly worse. This $quoted example is to match Operators like "=>" so it will need to catch more than whitespace and in this example, it will only match the second tag because it will only see this example as one tag: And it doesn't help my second point that is my biggest concern. Here is my current regex and where it fails: https://regex101.com/r/gMpPJU/1 I want it to match every "=>" on those lines {{ if a => b && c => d }}
{{ {if a => b} && {c => d} }} I can write all the failing tests and maybe you can help me TDD this 😄 The more I think about it, the more I think it has to be a sub language because I don't think we can do a recursive pattern in PHP PCRE without doing 2 successive preg_match_all |
Yeah you're probably right… but then we're stuck with the comments. However, we could fix comments like this:
I think that should fix all problems. Sorry for going back and forth on this, it's definitely one of the more difficult languages to parse solely with regex… PS: matching for that sub language should be as easy as |
No worries, I knew from the beginning that it was not an easy one 😄 So I go back to injecting AntlersTagLanguage() next to AntlersPhpInjection() and AntlersEchoInjection(), but this time comment pattern should be in the sub language? 749bc42#diff-e3e4595857edce00b02aa748801fcc680a123f0c105c0be5dd4d182b3f7f5469 Funny thing: Statamic was parsing Antlers with Regex in version 3, deprecated in version 4, recently removed in version 5. I'm sure it's for entirely different reasons, but worth noting. |
Does the refactor work? |
Sorry didn't do any changes, I referenced an old commit. It was working, except the comment thing. |
Ok I went back to the first version with the suggested changes. The current version renders like this, which I find even uglier: The first version was better I think. I spent way too many hours on this, going in circles. I give up here. 😅 |
I'll try to work on this next week and see what I can come up with :) |
Currently not gonna work on this, but might revisit later |
Hi Brendt! Love your work with console and highlight
Here is my contribution to support Antlers template language of Statamic.
It was pretty fun to code.
I like that way we can write tests in attributes.
I reused some Patterns from Xml and PHP, hope it's ok.
I noticed that there is no CSS for operators, is that a bug ?
❓Need help on one edge case
I tried several things to fix this bug without success. Is there a way to prevent injection into another injection ?
One thing I didn't tried is to put
#[After]
onAntlersCommentInjection
and remove other injections from$content
, is this the way ?📋 Before merging
Until you have time to review, here is a little preview 😃
🏞️ Preview
http://localhost:8080/?target=targets/antlers.md