notes

package
v0.95.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func CreatedAt(headers []string) time.Time

CreatedAt is when the note these headers belong to was first written, or the zero time when they do not say.

func Document

func Document(body string) string

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

func EditorHTML(input string) string

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

func HTMLToText(input string) string

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

func Headers(identifier string, createdAt time.Time) []string

Headers are the lines that make a message a note: its type, its identity and when it was first written.

func Identifier

func Identifier(headers []string) string

Identifier is the note identifier these headers carry, or empty when they are not a note's.

func IsEditable

func IsEditable(headers []string, html string) bool

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

func Preview(text string, limit int) string

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

func TextToHTML(text string) string

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.

func Title

func Title(text string) string

Title is what a note is called: its first line with anything in it, as on the phone, which names a note that way and writes the name as the Subject.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL