Documentation
¶
Overview ¶
Package notes is the format a phone's Notes app keeps a note in when it keeps its notes in a mail account: one message a note, in a folder of their own, a single HTML part, and a few headers of the phone's that say it is a note and which one. Every edit is a new message with the same identifier, and the old one is flagged deleted.
Reading and writing that format is here; where the notes are kept and who may change them is the mailbox's.
Index ¶
- Constants
- func CreatedAt(headers []string) time.Time
- func Document(body string) string
- func EditorHTML(input string) string
- func HTMLToText(input string) string
- func Headers(identifier string, createdAt time.Time) []string
- func Identifier(headers []string) string
- func IsEditable(headers []string, html string) bool
- func NewIdentifier() string
- func Preview(text string, limit int) string
- func TextToHTML(text string) string
- func Title(text string) string
Constants ¶
const ( // HeaderType says what kind of thing a message is; a note says TypeNote. HeaderType = "X-Uniform-Type-Identifier" // HeaderIdentifier is the note's identity, the same in every version of // it. The Message-ID is not: each version is a message of its own. HeaderIdentifier = "X-Universally-Unique-Identifier" // HeaderCreatedDate is when the note was first written, carried from // version to version, as an RFC 5322 date. HeaderCreatedDate = "X-Mail-Created-Date" // TypeNote is the value of HeaderType on a note. TypeNote = "com.apple.mail-note" )
The headers are the phone's contract and keep the phone's names.
const UneditableReason = "this note has pictures or attachments; change it on the phone"
UneditableReason is what a person is told when a note cannot be changed here: a new version is written from text or HTML alone, which would drop the pictures and attachments the phone keeps in the message.
Variables ¶
This section is empty.
Functions ¶
func CreatedAt ¶
CreatedAt is when the note these headers belong to was first written, or the zero time when they do not say.
func Document ¶
Document puts the body of a note in the document the phone writes around one. HTML that is already a document is left as it is.
func EditorHTML ¶
EditorHTML is a note's HTML made fit to put into the dashboard's own page, which is where its editor is. A message is shown in a frame of its own, and what is safe there is not safe here: a style block restyles the whole dashboard, and a class or an id borrows its rules. So the note keeps its text and its structure, and loses its style blocks, its classes and ids, and anything that could run: scripts and event handlers, which the input should not have left, are dropped here again rather than trusted.
func HTMLToText ¶
HTMLToText reads a note's HTML as the lines a person sees: a block a line, a line break a line, an empty block an empty line, and a list item a line starting "- ", which is what TextToHTML turns back into a list.
Not the reduction mail is read with, which surrounds every block with blank lines and then collapses them: a note's empty lines are the ones its writer typed, and the text an agent edits has to write back as the same note.
func Headers ¶
Headers are the lines that make a message a note: its type, its identity and when it was first written.
func Identifier ¶
Identifier is the note identifier these headers carry, or empty when they are not a note's.
func IsEditable ¶
IsEditable says whether a version of a note can be replaced by one written from its text or HTML without losing anything: not when the message has more than one part, which is how the phone keeps a picture or a file in a note, and not when the HTML shows a picture.
func NewIdentifier ¶
func NewIdentifier() string
NewIdentifier is an identifier for a new note, in the form the phone writes one: a random UUID in capitals.
func Preview ¶
Preview is what follows the title, on one line and cut to about limit characters: what a list of notes shows under each name.
func TextToHTML ¶
TextToHTML writes plain text as the phone writes a note: a div a line, an empty line as a div holding a line break, and a run of lines starting "- " as a list.
Types ¶
This section is empty.