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

[BUG] [Formatter] Issues supporting custom elements with custom_html #236

Closed
3 tasks done
danstewart opened this issue May 2, 2022 · 3 comments
Closed
3 tasks done
Labels

Comments

@danstewart
Copy link

System Info

  • OS: Fedora 36
  • Python Version: Python 3.10.4
  • djLint Version: 1.0.0
  • template language: Jinja2

Issue

We use custom HTML elements so have added a custom_html regex to handle them:

custom_html = '\w+-\w+-\w+-\w+,\w+-\w+-\w+,\w+-\w+'

This has mostly worked but I've run into an issue when I have a custom element tag with 4 parts, eg: <some-long-custom-element>.
Adding a djlint:off comment also doesn't stop the formatter.

BEFORE

<some-long-custom-element></some-long-custom-element>

{# djlint:off #}
<some-long-custom-element></some-long-custom-element>
{# djlint:on #}

{# djlint:off #}<some-long-custom-element></some-long-custom-element>{# djlint:on #}

AFTER

<some-long-custom -element>
</some-long-custom-element>
{# djlint:off #}
<some-long-custom -element></some-long-custom-element>
{# djlint:on #}
{# djlint:off #}<some-long-custom -element></some-long-custom-element>{# djlint:on #}

I've thrown up an example in this repository:
https://github.com/danstewart/djlint-issue

I've tried having a look at where it's going wrong but I'm struggling to figure it out.
It looks like custom_html regex is used in a few places and this regex just breaks things.

Is there a better way to support arbitrary custom HTML elements?

@danstewart danstewart added 🦠 bug Something isn't working 🧽 formatter labels May 2, 2022
@christopherpickering
Copy link
Contributor

Thanks! It looks like the issue is coming from the attribute compress. I'll put a fix out for this case shortly!

christopherpickering pushed a commit that referenced this issue May 2, 2022
## [1.0.1](v1.0.0...v1.0.1) (2022-05-02)

### Bug Fixes

* **custom attributes:** custom attributes separated by hyphen were split up during format ([1ce378c](1ce378c)), closes [#236](#236)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@danstewart
Copy link
Author

Wow, that was fast!
That works as expected, thanks a lot 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants