Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: concatenate output and support base64 image encoding #57

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

guilhermeprokisch
Copy link
Owner

@guilhermeprokisch guilhermeprokisch commented Sep 14, 2024

Summary

This PR introduces the ability to concatenate output from multiple files, including support for base64-encoded images. This enhancement improves the functionality of the see command when redirecting output to a file, especially for markdown documents with embedded images.

Key Changes

  1. Added base64 support to encode images in the output.
  2. Modified the main function to handle image files differently when stdout is not a terminal.
  3. Updated the render_image function to support base64-encoded image data.
  4. Enhanced the ImageViewer to visualize both file paths and base64 image data.

Implementation Details

  • Added the base64 crate as a new dependency.
  • In main.rs, images are now encoded to base64 and output as markdown image tags when redirecting.
  • render.rs now includes logic to decode and render base64 image data.
  • viewers.rs has been updated to handle base64-encoded images in the ImageViewer.

Impact

These changes allow users to:

  • Concatenate multiple files, including images, into a single output file.
  • Generate markdown-compatible output with embedded base64 images.
  • View base64-encoded images directly in the terminal.

Example Usage

see file1.md image.png file2.md > output.md

This command will now produce a single markdown file with the content of file1.md, the image embedded as a base64-encoded markdown image tag, and the content of file2.md.

@guilhermeprokisch guilhermeprokisch changed the title feat: concat and image concat b64 feat: concatenate output and support base64 image encoding Sep 14, 2024
@guilhermeprokisch guilhermeprokisch merged commit 19c77e7 into main Sep 14, 2024
6 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant