preview

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package preview fetches a remote pCloud file and renders it for display in a terminal viewport. Supported formats:

  • Markdown (.md, .markdown) → goldmark + chroma renderer
  • Source code (.go, .py, .js, .ts, …) → chroma syntax highlight
  • Plain text (.txt, .log) → raw, no highlight
  • PDF (.pdf) → ledongthuc/pdf text extraction
  • Images (.jpg, .png, .gif, .bmp, .webp) → image2ascii colored ASCII art
  • CSV (.csv) → aligned text table
  • XML (.xml) → chroma syntax highlight

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanPreview

func CanPreview(name string) bool

CanPreview reports whether the given filename has a supported preview format.

func Render

func Render(data []byte, name string, width, height int) (string, error)

Render renders raw file bytes to a string for terminal display. name is used purely for extension-based format detection. width and height are the available viewport dimensions; a 2-column border offset is subtracted from width here so all renderers stay within bounds.

func RenderFromURL

func RenderFromURL(downloadURL, name string, width, height int) (string, error)

RenderFromURL downloads the file at downloadURL and renders its content to a string suitable for display inside a bubbletea viewport. name is the original filename (used for format detection). width and height define the target terminal dimensions.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL