Documentation
¶
Overview ¶
Package render turns a document and its run results back into markdown.
Index ¶
- func Fence(lang, attrs, body string) string
- func Markdown(d *doc.Document, results []*run.Result, opts Options) []byte
- func NumberLines(s string, first int) string
- func Output(r *run.Result, withStderr bool) string
- func Pieces(d *doc.Document, results []*run.Result, opts Options) [][]byte
- func Prose(d *doc.Document, results []*run.Result, env []string) []byte
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Markdown ¶
Markdown renders d with results spliced in after their blocks. Blocks without a result, or that didn't run, keep the output already in the file. results may be nil, and is matched to blocks by position.
func NumberLines ¶ added in v1.1.0
NumberLines starts each line of s with its number, counting from first.
func Output ¶
Output renders one block's result as the markdown that follows it. stderr is included only when withStderr is set; mdsh's own errors always are. It returns "" when there is nothing to show.
Types ¶
type Options ¶
type Options struct {
// HideCode leaves out runnable blocks. Other code blocks are part of
// the prose and stay.
HideCode bool
// HideOutput leaves out output, old and new.
HideOutput bool
// WriteBack renders for saving to the file: the #! line stays,
// placeholders keep their {{...}} form with the new value inside, and
// nothing is left out by show=, show-output= or mdsh:if sections.
// Otherwise the #! line and section markers are dropped, placeholders
// print as values, and conditions decide what shows.
WriteBack bool
// Env is the caller's environment, for {{$VAR}}. Nil means unknown:
// placeholders keep their stored values and conditions read empty.
Env []string
}
Options control what Markdown prints.