report

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 20 Imported by: ? 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 report turns a run into a file to share: the printed markdown, a standalone HTML page or a PDF. The CLI's --pdf and --html and the GUI's Report dialog both use it, so they make the same reports.

Index

Constants

This section is empty.

Variables

View Source
var Formats = []Format{PDF, HTML, Markdown}

Formats lists every format, in the order a menu shows them.

Functions

func Render

func Render(d *doc.Document, results []*run.Result, opts Options) ([]byte, error)

Render makes a report of d with results, matched to its blocks as render.Markdown matches them. Blocks without a result show the output saved in the file, so run.Includes(d, ...) as results reports the file as it was last saved, running nothing.

func Title

func Title(file string) string

Title is a report title for file: its name without the extension.

Types

type Format

type Format string

Format is a kind of report.

const (
	// Markdown is what mdsh prints: placeholders as values, mdsh:if
	// sections decided, and no #! line. It is what mdsh -n -o saves.
	Markdown Format = "markdown"
	// HTML is a standalone page, with local images inside it.
	HTML Format = "html"
	// PDF is what mdsh --pdf writes.
	PDF Format = "pdf"
)

func FormatOf

func FormatOf(path string) (Format, bool)

FormatOf names the format a file's extension asks for.

func (Format) Ext

func (f Format) Ext() string

Ext is the format's usual file extension, with its dot.

type Options

type Options struct {
	Format Format
	// HideCode leaves out runnable blocks, as --hide-code does.
	HideCode bool
	// HideOutput leaves out output, as --hide-output does.
	HideOutput bool
	// Env is the caller's environment, for {{$VAR}} placeholders and
	// conditions; see render.Options.
	Env []string
	// Dir is where relative image links are read from, for HTML and
	// PDF. Empty means the working directory.
	Dir string
	// Title is the report's title. Empty means none for a PDF and
	// "mdsh report" for an HTML page.
	Title string
}

Options control what a report shows.

Jump to

Keyboard shortcuts

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