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
Image formatter #245
Comments
I think that would be great. FWIW, Pygments has image formatters. A PDF formatter would also be amazing, but I suspect that would be quite a bit more work. |
SVG would be awesome too.. and maybe that would be a) easier and b) fulfil the image requirements you need? |
Thanks! I've been exploring Go-native PDF writers, and seems like @jung-kurt's https://github.com/jung-kurt/gofpdf is the most battle-tested solution (yet it's a port of PHP's FPDF library, so design is not idiomatic and it lacks some features like proper Unicode support in PDF). But I use it in production for years, and it works great, I might try to implement PDF Formatter based on it. There is also fantastic in terms of code quality and PDF spec coverage https://github.com/unidoc/unidoc library, but it has very unusual licensing, which stops me from using it everywhere. SVGI'm not sure I know how well SVG handles font rendering, but I know @ajstarks hack SVG things for breakfast, so maybe his input will be valuable here. ImagesFor images (I need PNG output for my case), I think the main challenge will be handling fonts and layout. I'll explore it to understand a scope of work. |
This is awesome.
Use the same approach as the HTML formatter; function options to configure it, and map those to a set of flags with |
I guess my only slight concern is that it pulls in a fairly large set of dependencies, but the functionality is super nice so I'm okay with that.
Yes, good idea. Something like |
Any progress on this? |
Nope, sorry, I used it just once. |
Had a look at |
Nice! Does it handle text wrapping? Send a PR and we'll merge it in. |
No (https://www.oreilly.com/library/view/svg-text-layout/9781491933817/ch04.html), but should be possible to add a maxwidth (characters) options and then split the lines programatically in the formatter. |
So we now have SVG support thanks to @rsteube, I think this can be closed! |
I'd love to use Chroma for generating screenshots of the code – from short carbon.sh-like ones to the long whole files screenshots.
Turns out, making long code screenshot it's not a trivial task and most tools solve it by scrolling window and stitching it together. I believe chroma's concept of Formatters is perfect for implementing this functionality natively.
I might be willing to work on this in my spare time, but I want to check that I'm not duplicating work and not missing something crucial (perhaps it's in progress already, or there some limitations I'm not aware of).
Thanks in advance for thoughts on this.
The text was updated successfully, but these errors were encountered: