render

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render turns a work into a file to send. Each kind of file is a Format: adding one is a type that implements it and a line in main that adds it to the Set; the mind and the console offer whatever the Set has.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoData = errors.New("render: the work doesn't carry what this file is made from")

Functions

func FileName

func FileName(title, ext string) string

FileName is title as a file name with ext, like "clinic-outreach-plan.pdf".

Types

type DataFormat

type DataFormat interface {
	Format
	// DataSchema is the data for Structured Outputs; DataHelp tells System 2
	// how to write it.
	DataSchema() map[string]any
	DataHelp() string
	// CleanData keeps what can be used of raw; an error if nothing can.
	CleanData(raw json.RawMessage) (json.RawMessage, error)
}

DataFormat is a format made from data a work carries beside its words, which it defines: a craft that names the data (character.yaml's data) gets it written with each work.

type File

type File struct {
	Name string
	Type string // media type
	Data []byte
}

type Format

type Format interface {
	Name() string // what a promise's "as" and a reply's send.as say, e.g. "pdf"
	Ext() string
	MediaType() string
	// Describe is how the person knows the file, like "a PDF document, to
	// print, attach or pass on"; WriteHelp is how to write a work meant to go
	// as one, or "".
	Describe() string
	WriteHelp() string
	// Needs is the data a work must carry to be this file (memory.Work.Carries);
	// "" if its words are enough. A format that needs data is a DataFormat.
	Needs() string
	Render(w memory.Work, author string) ([]byte, error)
}

type Set

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

A nil Set has no formats.

func NewSet

func NewSet(formats ...Format) *Set

func (*Set) All

func (s *Set) All() []Format

All is in the order NewSet was given.

func (*Set) Data

func (s *Set) Data(kind string) (DataFormat, bool)

Data is the format that defines data of kind.

func (*Set) DataKinds

func (s *Set) DataKinds() []string

DataKinds is the data its formats are made from, each once, in the order NewSet was given.

func (*Set) File

func (s *Set) File(format string, w memory.Work, author string) (File, error)

func (*Set) For

func (s *Set) For(w memory.Work) []Format

For is the formats w can be made into now.

func (*Set) Get

func (s *Set) Get(name string) (Format, bool)

Directories

Path Synopsis
Package archive is data a work carries: files with their paths, like the code of a small program, made into a zip.
Package archive is data a work carries: files with their paths, like the code of a small program, made into a zip.
Package calendar is data a work carries: dated events, made into an iCalendar (.ics) file that adds them to any calendar app.
Package calendar is data a work carries: dated events, made into an iCalendar (.ics) file that adds them to any calendar app.
Package docx writes a work's words as a Word document, laid out from its Markdown with Word's own styles (Title, Heading 1 to 9, lists, Quote, tables), so it can be edited as one.
Package docx writes a work's words as a Word document, laid out from its Markdown with Word's own styles (Title, Heading 1 to 9, lists, Quote, tables), so it can be edited as one.
Package markdown reads a work's words as Markdown into a flat list of blocks for a format to lay out.
Package markdown reads a work's words as Markdown into a flat list of blocks for a format to lay out.
Package midi writes a score (tracks of notes, placed by bar and beat) as a standard MIDI file that any DAW opens.
Package midi writes a score (tracks of notes, placed by bar and beat) as a standard MIDI file that any DAW opens.
Package pdf lays a piece of writing out as an A4 PDF: its title, then its text read as Markdown (render/markdown).
Package pdf lays a piece of writing out as an A4 PDF: its title, then its text read as Markdown (render/markdown).
Package table is data a work carries: a table of rows and columns, made into a spreadsheet (XLSX) or a CSV file.
Package table is data a work carries: a table of rows and columns, made into a spreadsheet (XLSX) or a CSV file.

Jump to

Keyboard shortcuts

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