format

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package format contains functions for producing a CodeReader from a stream that contains markdown files with fishi codeblocks. A CodeReader can be sent directly to the frontend and handles all gathering of codeblocks and running any preprocessing needed on it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeReader

type CodeReader struct {
	// contains filtered or unexported fields
}

CodeReader is an implementation of io.Reader that reads fishi code from input containing markdown-formatted text with fishi codeblocks. It will gather all fishi codeblocks immediately on open and then read bytes from them as Read is called. Preprocessing may also be done at that time. The CodeReader will return io.EOF when all bytes from fishi codeblocks in the stream have been read.

func NewCodeReader

func NewCodeReader(r io.Reader) (*CodeReader, error)

NewCodeReader creates a new CodeReader from a stream containing markdown formatted text with fishi codeblocks. It will immediately read the provided stream until it returns EOF and find all fishi codeblocks and run preprocessing on them.

Returns non-nil error if there is a problem reading the markdown or preprocessing the code.

func (*CodeReader) Read

func (cr *CodeReader) Read(p []byte) (n int, err error)

Read reads bytes from the CodeReader. It will return io.EOF when all bytes from fishi codeblocks in the stream have been read. It cannot return an error as the actual underlying stream it was opened on is fully consumed at the time of opening.

Jump to

Keyboard shortcuts

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