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

Minify ? #25

Open
yabdab opened this issue Sep 22, 2023 · 6 comments
Open

Minify ? #25

yabdab opened this issue Sep 22, 2023 · 6 comments
Labels
feature request New feature

Comments

@yabdab
Copy link

yabdab commented Sep 22, 2023

Is there a way to "minify" ( remove all extra spaces and line-breaks ) from a selection using Text Tools?

@biati-digital
Copy link
Owner

Do you have an example? before and after of what you want to achieve?

@yabdab
Copy link
Author

yabdab commented Sep 23, 2023

Before:

<svg xmlns="http://www.w3.org/2000/svg"
           height="1em"
           viewBox="0 0 512 512">
        <path
              d="M0 96C0 60.7 28.7 32 64 32H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h96 32H424c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z" />
</svg>

After:

<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><path d="M0 96C0 60.7 28.7 32 64 32H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h96 32H424c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>

@biati-digital
Copy link
Owner

Thank's for the example, not possible for now but I'll see if it can be added in a future update.

@biati-digital biati-digital added the feature request New feature label Sep 27, 2023
@yabdab
Copy link
Author

yabdab commented Sep 27, 2023

OK. All it needs to do is replace all the double spaces/tabs and line breaks with an empty string.
Fingers crossed it makes it into a future update. Cheers.

@yabdab
Copy link
Author

yabdab commented Sep 29, 2023

I added this to your extension and it works pretty well for what I needed. Feel free to include it in main build if you like?

minifySelection(text) {
    return text.replace(/>\s+</g, '><').replace(/\s+/g, ' ')
  }

@biati-digital
Copy link
Owner

Thank's for sharing that code but it's really specific to your needs, it will not work for many other cases for example CSS, Python, etc. If this is implemente it will require a lot of testing to make sure it works.

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

No branches or pull requests

2 participants