-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Implement --prettify parameter (only supports HTML for now). #7825
base: master
Are you sure you want to change the base?
Conversation
This is similar to --minify, but has essentially the opposite effect: instead of making the output less readable it makes it *more* readable. This uses github.com/yosssi/gohtml to perform the actual transformation. Fixes gohugoio#7190
Oh, sorry @nu8, I forgot to add that to the configuration syntax above. (I'll edit it in) You can enable like this: prettify:
prettifyOutput: true This is basically the same as how |
I think it depends on how you structure your pages, but yes I've noticed that too if there are no tags on either end of the white space. Like the first message says, this implementation uses If you know of a better HTML formatting lib written in Go though, feel free to suggest it. (I did look around a bit and this is definitely the most popular one I found at least) Alternatively, you could raise this issue in https://github.com/yosssi/gohtml and/or submit a PR there. |
Ah yes, that will also "break" it. 🤣 |
Hey, thanks for this and sorry for the delay. I need to wait with this. I looked into the gohtml package in relation with something else, and there are some bugs in there that means we cannot use this (my memory is a little hazy, but it's related to whitespace handling with text and span elements). I looked into fixing this upstream, but that looked hard ... I have been tinkering with my own html formatter Go package, which I think will get ready soonish ... will let you know. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Is there a chance of this work making it into a future release of Hugo? |
This PR has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Please don't close this, I would love this feature! |
I'd be interested in this too. Commenting to keep it alive. |
I too would love to see this get in. |
Just to say that I was looking for exactly this in Hugo! Would love to see it integrated. ❤️ |
This is similar to
--minify
, but has essentially the opposite effect: instead of making the output less readable it makes it more readable.This uses
github.com/yosssi/gohtml
to perform the actual transformation.Fixes #7190
The default configuration currently looks like this:
which is based on the defaults of
gohtml
.I'm especially looking for feedback on whether the interface (parameter name and config syntax) are reasonable.
TODOs:
gohtml
, right?gohtml
globals in the initializer.gohtml
supportsLineWrapColumn
andLineWrapMaxSpillover
.Stuff that may happen later:
encoding/json
, I haven't looked into others.Resources.Prettify
pipeline function so it can be used from there too.