Documentation ¶
Index ¶
- type ContentReader
- func (cr ContentReader) CreateContent(filepath string, data []byte) (string, error)
- func (cr ContentReader) Format(filepath string, data []byte) (string, error)
- func (cr ContentReader) IOReader(source io.Reader, filepath string) (string, error)
- func (cr ContentReader) JoinAll(results []string) string
- func (cr ContentReader) ReadAll() (string, error)
- func (cr ContentReader) ReadFile(filepath string) (string, error)
- func (cr ContentReader) ReadFilesAsync(paths []string) ([]string, error)
- func (cr ContentReader) Readable(filePath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentReader ¶
type ContentReader struct {
Config *options.Config // Configuration options for content reading and formatting.
}
ContentReader is responsible for reading and processing content from files or standard input.
func (ContentReader) CreateContent ¶ added in v1.6.0
func (cr ContentReader) CreateContent(filepath string, data []byte) (string, error)
CreateContent creates a formatted string from raw data and applies formatting based on the configuration.
func (ContentReader) Format ¶ added in v1.6.0
func (cr ContentReader) Format(filepath string, data []byte) (string, error)
Format formats the content based on configuration options (HTML, Markdown, MimeType). It returns the formatted content as a string and an error if formatting fails.
func (ContentReader) IOReader ¶ added in v1.6.0
IOReader reads content from an io.Reader (e.g., a file or stdin). It returns the content as a string and an error if reading fails.
func (ContentReader) JoinAll ¶ added in v1.6.0
func (cr ContentReader) JoinAll(results []string) string
JoinAll aggregates the content from the provided results and returns it as a single string. It combines the content of all readers into a single string with newline separators.
func (ContentReader) ReadAll ¶ added in v1.6.0
func (cr ContentReader) ReadAll() (string, error)
ReadAll reads content from multiple files concurrently or from standard input if no files are specified. It returns the aggregated content as a single string.
func (ContentReader) ReadFile ¶ added in v1.6.0
func (cr ContentReader) ReadFile(filepath string) (string, error)
ReadFile reads and formats content from a single file. It returns the formatted content as a string and an error if the file cannot be read or formatted.
func (ContentReader) ReadFilesAsync ¶ added in v1.6.0
func (cr ContentReader) ReadFilesAsync(paths []string) ([]string, error)
ReadFilesAsync reads content from multiple files concurrently using goroutines. It returns a slice of strings containing the content of each file and an error if any file reading fails.
func (ContentReader) Readable ¶ added in v1.6.0
func (cr ContentReader) Readable(filePath string) error
Readable checks if a file path exists, is a regular file, and has read permissions. It returns an error if the file is not accessible or readable.