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

Crazy long regex for text.html.basic #73

Open
evoactivity opened this issue Feb 14, 2024 · 5 comments
Open

Crazy long regex for text.html.basic #73

evoactivity opened this issue Feb 14, 2024 · 5 comments

Comments

@evoactivity
Copy link
Contributor

@lifeart Do you have any idea what this particular regex is for? I've ignored it whilst I've worked on this assuming someone somewhere needs it, but it seems hyper specific.

I'll probably remove it unless you know why it exists 😄

'(?ix:\n\t\t\t\t\t\t\t\t\t\t\t\t(?=\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype\\s*=\\s*\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\'|"|)\n\t\t\t\t\t\t\t\t\t\t\t\t\ttext/\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx-handlebars\n\t\t\t\t\t\t\t\t\t\t\t\t\t | (x-(handlebars-)?|ng-)?template\n\t\t\t\t\t\t\t\t\t\t\t\t\t | html\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\\s"\'>]\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)',

@lifeart
Copy link
Owner

lifeart commented Feb 15, 2024

@evoactivity looks like a copy-pasta from smf, ya, it looks not needed, let’s delete it

UPD: Ah, it's for handlebars cases like:

<script type="text/x-handlebars">
  foo
  {{bar}}
</script>

<script id="entry-template" type="text/x-handlebars-template">
  <div class="entry">
    <h1>{{title}}</h1>
  </div>
</script>

And we not planning to support it, so could be removed.

@flashios09
Copy link
Contributor

flashios09 commented Feb 17, 2024

@lifeart Do you have any idea what this particular regex is for? I've ignored it whilst I've worked on this assuming someone somewhere needs it, but it seems hyper specific.

I'll probably remove it unless you know why it exists 😄

'(?ix:\n\t\t\t\t\t\t\t\t\t\t\t\t(?=\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype\\s*=\\s*\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\'|"|)\n\t\t\t\t\t\t\t\t\t\t\t\t\ttext/\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx-handlebars\n\t\t\t\t\t\t\t\t\t\t\t\t\t | (x-(handlebars-)?|ng-)?template\n\t\t\t\t\t\t\t\t\t\t\t\t\t | html\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\\s"\'>]\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)',

Just remove the \t, \n and \s and it will be so easy to read:

?ix:(?=type=('|")text/(x-handlebars|(x-(handlebars-)?|ng-)?template|html)["'>])

So this will capture type="text/html", type="text/x-handlebars-template" ...

<script id="entry-template" type="text/x-handlebars-template">
  <div class="entry">
    <h1>{{title}}</h1>
    <div class="body">
      {{body}}
    </div>
  </div>
</script>

It's on the official handlebars website: https://handlebarsjs.com/installation/#usage !

@flashios09
Copy link
Contributor

flashios09 commented Feb 17, 2024

@lifeart why we would remove it ?
I'm still using <script type="text/x-handlebars-template">...</script> in some side projects where i just need a lightweight syntax template like handlebars:
image

@lifeart
Copy link
Owner

lifeart commented Feb 17, 2024

@flashios09 I'm glad we able to figure out usages for this expression, not pushing removing here, since we have real use-case for it. Wondering if we could simplify it a bit (removing bunch of \t)

@evoactivity
Copy link
Contributor Author

Simplification is fine, I'm glad you caught this @flashios09, that's why I created an issue for this one instead of just going ahead and removing.

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

No branches or pull requests

3 participants