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

encoding: Add the ZlibCompress function #12867

Closed
wants to merge 1 commit into from

Conversation

razonyang
Copy link
Contributor

The PR adds zlib compression support to the template, which is useful for generating Kroki diagrams without requiring remote APIs, reducing build time and avoiding network issues.

Template usage:

{{ $diagram := `blockdiag {
  Kroki -> generates -> "Block diagrams";
  Kroki -> is -> "very easy!";

  Kroki [color = "greenyellow"];
  "Block diagrams" [color = "pink"];
  "very easy!" [color = "orange"];
}`
}}
{{- $encoded := encoding.ZlibCompress $diagram | encoding.Base64Encode }}
{{- $encoded = replace $encoded "+" "-" }}
{{- $encoded = replace $encoded "/" "_" }}
{{- $encoded = replace $encoded "=" "" }}
<img src="https://kroki.io/blockdiag/svg/{{ $encoded }}">

If this feature is not going to be accepted, please feel free to close it.

@bep
Copy link
Member

bep commented Sep 20, 2024

See https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#code-contribution

Any non-trivial code change needs to update an open issue. A non-trivial code change without an issue reference with one of the labels bug or enhancement will not be merged.

Create a proposal first.

@bep bep closed this Sep 20, 2024
@razonyang
Copy link
Contributor Author

Sorry I missed that, issue created #12868.

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

Successfully merging this pull request may close these issues.

2 participants