Documentation
¶
Overview ¶
Package format holds the text helpers the commands share when rendering API results: storage-XHTML decoding, search highlight-marker stripping and indentation.
Nothing here is part of an edit round-trip. A page body that will be written back is read from and written to a file untouched, so that path stays byte-lossless; the conversions in this package produce output for reading only. StripStorage exists because the comment endpoints refuse body-format=view, so comment bodies arrive as storage XHTML and have to be made readable locally, and ToMarkdown converts a page body for `read --markdown`, whose output carries no sidecar and cannot be updated.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Indent ¶
Indent prefixes every line of text, leaving blank lines unpadded so no trailing whitespace is emitted.
func StripHighlightMarkers ¶
StripHighlightMarkers removes the markers Confluence search wraps around matched terms and decodes the HTML entities that come with them. A value without markers passes through unchanged, so this is safe to apply even if the server stops adding them.
func StripStorage ¶
StripStorage turns storage XHTML into readable plain text on a best-effort basis: text is kept, block elements become line breaks, list items get a bullet, and user mentions become their account ID.
Types ¶
type Options ¶
type Options struct {
// UserNames maps an Atlassian account ID to a display name.
UserNames map[string]string
// PageURLs maps a link target to the page's URL.
PageURLs map[PageRef]string
}
Options carries the reference resolution ToMarkdown cannot do itself. The converter is a pure function, so looking a name or a URL up — which needs the API — happens in the command layer and arrives here as data. A zero Options is valid: every reference falls back to what the body already carries.
type PageRef ¶
PageRef names a page the way storage links to one: by space key and title, with no page ID anywhere in the body.
type Result ¶
type Result struct {
Markdown string
// Unsupported names the macros and extensions that became placeholders,
// deduplicated and sorted; UnsupportedCount counts every occurrence. A
// reader decides from these whether the rendering can be trusted, without
// having to read the whole file first.
Unsupported []string
UnsupportedCount int
}
Result is a conversion and what it could not represent.
func ToMarkdown ¶
ToMarkdown converts a storage-format body to Markdown for reading. It never fails: unknown input degrades in structure, never in content, so an element this converter has never seen still yields the text inside it.