Documentation
¶
Overview ¶
Package render turns the document model into text for the model to read: markdown (default), plain text, and an outline. Every renderer works on a block range of one segment so reads can be scoped and budgeted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentThreads ¶ added in v0.4.0
CommentThreads lists whole threads, each with its replies under it. The caller writes the count line above.
func NamedStyle ¶ added in v0.5.0
func NamedStyle(d *doc.NamedStyleDef) string
NamedStyle describes what a named style means, for the reads that report the definitions layout_document can rewrite. Unlike styleAnnotation it names bold and italic too: here there is no markdown around it to show them.
Types ¶
type DiffResult ¶ added in v0.2.0
DiffResult is a rendered unified diff.
func UnifiedDiff ¶ added in v0.2.0
func UnifiedDiff(oldText, newText string, context, maxChars int) DiffResult
UnifiedDiff renders the line-level differences between two texts in unified-diff form with the given lines of context, cut at a hunk boundary when the output would exceed maxChars (0 = no limit).
type DiffStats ¶ added in v0.2.0
type DiffStats struct {
Added int `json:"added_lines"`
Removed int `json:"removed_lines"`
Hunks int `json:"hunks"`
}
DiffStats count the changed lines of a diff.
type Mark ¶ added in v0.2.0
Mark is a comment thread where a read found it. A located thread names the segment and range it sits on; an unlocated one (no handle) is only counted. Replies is a count, not the posts: the footer says how many there are, and list_comments is where they are read.
type Options ¶
type Options struct {
// WithHandles prefixes every block with its handle.
WithHandles bool
// WithStyles annotates runs whose formatting markdown cannot express.
WithStyles bool
// Suggestions shows pending suggestions as CriticMarkup. When false
// the committed view is rendered (suggested insertions hidden).
Suggestions bool
// MaxChars stops after the block that would cross the budget. 0 = no limit.
MaxChars int
// Marks are comment threads to show as {>>c:<id><<} after the text
// they cover, and to list below the content when CommentFooter is set.
Marks []Mark
// rendered range and counts the ones outside it.
CommentFooter bool
}
Options tune a render.
type OutlineHeading ¶
type OutlineHeading struct {
Handle string `json:"handle"`
HeadingID string `json:"heading_id,omitempty"`
Level int `json:"level"`
Text string `json:"text"`
Blocks int `json:"blocks"`
Words int `json:"words"`
}
OutlineHeading is one heading in the outline.
type OutlineTab ¶
type OutlineTab struct {
Number int `json:"number"`
ID string `json:"id,omitempty"`
Title string `json:"title"`
Nesting int `json:"nesting,omitempty"`
Paragraphs int `json:"paragraphs"`
Tables int `json:"tables"`
Words int `json:"words"`
Headers int `json:"headers"`
Footnotes int `json:"footnotes"`
Preamble int `json:"preamble_blocks"`
Headings []OutlineHeading `json:"headings"`
}
OutlineTab is one tab's outline.
func OutlineData ¶
func OutlineData(d *doc.Document, only *doc.Tab) []OutlineTab
OutlineData computes the outline for the tabs given (all when nil).
type Reply ¶ added in v0.4.0
type Reply struct {
Author string
Content string
Created string
Action string // resolve or reopen
Deleted bool
}
Reply is one post in a thread after the first.
type Result ¶
Result is a rendered block range. To is the index one past the last block the render consumed (the continuation point when truncated).
type Thread ¶ added in v0.4.0
type Thread struct {
ID string
Handle string
Author string
Created string
Quote string
Content string
Resolved bool
Deleted bool
Replies []Reply
}
Thread is a comment thread. It is shown twice: as one line in the footer of a read that marked it inline, and in full with its replies for list_comments. A view sets only the fields it wants shown — the footer leaves Created and Quote empty, because the read already shows the marked text where it sits.