Documentation
¶
Overview ¶
Package md is a small typed Markdown builder for magus's generated docs (MAGUS.md, the insight report). It replaces hand-concatenated markdown with block-level primitives - headings, paragraphs, tables, code fences, lists - so table pipes, fence closing, and block spacing are written once here instead of at every call site. Every block method leaves exactly one blank line after itself, so blocks compose without callers tracking spacing.
It is a builder, not a renderer: output goes wherever the caller writes it (emit, never render). Cell and label text is taken verbatim - inputs are sanitized at graph ingest, and generated docs deliberately embed inline markdown (backticks, bold) in cells.
Index ¶
- func Bold(s string) string
- func Code(s string) string
- func Codes(labels []string) string
- func Link(text, href string) string
- type Align
- type Builder
- func (b *Builder) AlignedCodeBlock(lang string, lines []CodeLine)
- func (b *Builder) Bytes() []byte
- func (b *Builder) CodeBlock(lang string, lines ...string)
- func (b *Builder) Comment(text string)
- func (b *Builder) Details(summary string, body func(*Builder))
- func (b *Builder) Fenced(lang string, emit func(io.Writer) error) error
- func (b *Builder) Grow(n int)
- func (b *Builder) Heading(level int, text string)
- func (b *Builder) List(items ...string)
- func (b *Builder) Paragraph(text string)
- func (b *Builder) Paragraphf(format string, args ...any)
- func (b *Builder) Quote(lines ...string)
- func (b *Builder) Raw(s string)
- func (b *Builder) Table(header []string, align []Align, rows [][]string)
- func (b *Builder) WriteTo(w io.Writer) (int64, error)
- type CodeLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder accumulates a Markdown document. The zero value is ready to use.
func (*Builder) AlignedCodeBlock ¶
AlignedCodeBlock writes a fenced code block of code lines with their trailing "# note" comments aligned into one column. A line with an empty note carries no comment.
func (*Builder) Comment ¶
Comment writes an HTML comment block (e.g. the "generated, do not edit" marker).
func (*Builder) Details ¶
Details writes a <details> disclosure block: the summary line, a blank line, then whatever body writes into the builder.
func (*Builder) Fenced ¶
Fenced writes a fenced block whose body comes from emit (e.g. a Mermaid emitter that takes an io.Writer). The fence is closed even when emit fails, but the error is returned as-is.
func (*Builder) Paragraphf ¶
Paragraphf writes a formatted paragraph block.
func (*Builder) Quote ¶ added in v0.4.0
Quote writes a blockquote block, one "> line" per entry. Unlike Comment it renders, so it suits a note the reader is meant to see. No-op when empty.
func (*Builder) Raw ¶
Raw writes s verbatim - the escape hatch for shapes the primitives don't cover. Callers own the trailing blank line.
func (*Builder) Table ¶
Table writes a GFM table: a header row, the alignment delimiter row, then one row per entry. align may be nil (all Left) or shorter than header (the tail defaults to Left). Cells are written verbatim; callers pre-format values (and may embed inline code). No-op when there are no rows.