Documentation
¶
Index ¶
- func ExtractImageURLs(s string) []string
- func FromMarkdown(md string) string
- func MarkdownIsLossless(s string) bool
- func MessageSourceText(s string) string
- func PrependHTML(content, note string) string
- func ToText(s string) string
- func UnwrapTrixContent(s string) string
- type Attachment
- type Markdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractImageURLs ¶
ExtractImageURLs finds image URLs from <img src> tags and <figure data-trix-attachment> elements.
func FromMarkdown ¶ added in v1.0.0
FromMarkdown converts Markdown the user wrote into HTML for one of HEY's rich-text fields: a message body, a journal entry, a contact note, a snippet.
func MarkdownIsLossless ¶ added in v1.8.0
MarkdownIsLossless reports whether ToMarkdown keeps everything in s that FromMarkdown can write back. It is false when s holds something Markdown has no syntax for — a Trix attachment, an image, a table, underline, an attribute such as a colour or a list's starting number, formatting inside code, nesting deeper than ToMarkdown renders, line breaks Markdown cannot place — or a link ToMarkdown will not write, because writing the Markdown back in place of s would lose it.
func MessageSourceText ¶ added in v0.2.0
MessageSourceText returns the source-backed text carried by HTML message content.
func PrependHTML ¶ added in v1.0.0
PrependHTML adds an HTML note before existing HTML content.
func UnwrapTrixContent ¶ added in v1.8.0
UnwrapTrixContent takes off the <div class="trix-content"> that HEY puts around rich text it serves for editing — a contact note's note_html, a journal entry's content_html. That div is Action Text's layout rather than part of what was written, and HEY adds it again on every read, so HTML read from HEY and written back as it is sinks one div deeper each time.
Only the layout is taken off: a div carrying exactly class="trix-content", which is all the layout writes, standing first in the HTML — with or without what was added after it — and again at the start of what it held, which is where earlier round trips nested it. A div like that anywhere else, or one with any other attribute or class, is the author's and is kept. HTML with nothing to take off is returned as it came.
Types ¶
type Attachment ¶
type Attachment struct {
URL string
Filename string
ContentType string
ByteSize *int64
SGID string
// Embedded reports whether the file comes from an opaque embedded HTML body.
Embedded bool
}
Attachment describes a downloadable file embedded in rich-text content.
func ExtractAttachments ¶
func ExtractAttachments(s string) []Attachment
ExtractAttachments returns downloadable files in their document order.
type Markdown ¶ added in v0.2.0
type Markdown struct {
// contains filtered or unexported fields
}
Markdown is Markdown that ToMarkdown produced: every context serialized on its own terms, and no control character left in it other than the newlines and tabs that Markdown itself is written with — a fence keeps its tabs, and a sink that shows it sanitizes with the same two allowed. It is the only kind of Markdown markdown.Render accepts, and nothing but ToMarkdown can make one — the field is unexported and there is no constructor — so a body from anywhere else cannot reach a terminal renderer by being a string that happens to look like Markdown. It marshals to JSON as the string it holds, which is what --json carries.
func ToMarkdown ¶ added in v0.2.0
ToMarkdown converts HTML content to Markdown. Unlike ToText it keeps what a flattened email throws away: link URLs, emphasis, headings, list nesting, quotes, code blocks and tables. What it returns is the only Markdown markdown.Render accepts; see the Markdown type.
func (Markdown) IsEmpty ¶ added in v0.2.0
IsEmpty reports Markdown with nothing in it; IsZero is the same, for `omitzero`.
func (Markdown) MarshalText ¶ added in v0.2.0
MarshalText writes the Markdown as a JSON string.