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

Feature request: Option to strip/reduce all whitespace, not just in text. #49

Open
pbsds opened this issue Apr 6, 2022 · 3 comments
Open

Comments

@pbsds
Copy link

pbsds commented Apr 6, 2022

It would be nice to be able to collapse each match into a single line, for further filtering with tools like grep.
For example, when matching table rows, each row often span multiple lines, due to how the html was formatted.

My current workaround is to minify the html before passing it to htmlq (cat myfile.html | sd '\n' ' ' | tr -s ' ' | htmlq ...), but a simple switch in htmlq would make this way easier.

Not sure how this would be handled in tags like pre tough...

@kllmanu
Copy link

kllmanu commented Jul 12, 2023

@pbsds I guess you mean sed not sd?

@pbsds
Copy link
Author

pbsds commented Jul 12, 2023

Sorry, i'm so used to sd i didn't notice.

cat myfile.html | sed -ze 's/\n/ /g' | tr -s ' ' | htmlq ...

@kllmanu
Copy link

kllmanu commented Jul 12, 2023

@pbsds Thanks, didn't know about this one, will add it to my toolbelt!

I just ended up using xargs for the whitespace, which seems to beasier for me:

cat myfile.html | htmlq ... | xargs | htmlq ...

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

2 participants