Skip to main content

Module content

Module content 

Source
Expand description

What a note says, taken apart for showing: plain text, links, mentions of people, hashtags, the images and the videos it carries, the notes it quotes, and the web page it is shown a preview of.

Images, videos and quoted notes are set aside from the text: what stands for them in it is an address, and they are shown under it for what they are.

What a link is is told by how its address ends, and by what the note says of it in a NIP-92 imeta tag (see Attachment): a link the note calls a video is one, whatever its address looks like. A link to a YouTube video is a video too (see crate::youtube), though what is at its address is a page.

The text is split by nostr’s own parser, so what counts as a URL, a nostr: URI or a hashtag is what the rest of the ecosystem agrees on.

Before that, what the note marks as Markdown is taken for what it is (see markdown): the text comes here as runs, each in one style, and each run is read for its links, mentions and hashtags. A note that marks nothing is one run, and is read as it always was.

Structs§

Attachment
What a note says of something it links to, in a NIP-92 imeta tag: ["imeta", "url https://…", "m video/mp4", "dim 1920x1080", …].
Builder 🔒
Builds a Content, counting what it shows and stopping at a limit.
Content
A note’s content, parsed, and cut to what a feed row shows.
NoteImage
An image a note carries: a link to a picture, shown under the text rather than in it.
NoteVideo
A video a note carries: a link to one, played under the text rather than followed from it.
Quote
Another note a note quotes: one it names by its address in the text (nostr:note1…, nevent1…). Shown under the text, as the note it is when that is at hand, and as a link to it when it isn’t.
Whole
The text of a note that was cut, all of it: what its row shows once it is asked for the rest.

Enums§

Named 🔒
What a nostr: URI stands for in a note.
Segment
One piece of a note, in reading order.

Constants§

CODE_CHARS_PER_FOUR 🔒
How many characters of text four of code take the room of: its letters are all as wide as the widest.
FEED_NOTE_MAX_CHARS
How much of a note a feed row shows, in characters, until it is asked for the rest. A long note is cut here, and what it says in full is kept beside what is shown of it (see Content::whole).
FILE_EXTENSIONS 🔒
The file extensions of what is plainly not a web page: nothing with a title to preview it by, and not worth asking.
IMAGE_EXTENSIONS 🔒
The file extensions of the pictures that can be decoded and shown.
LINK_LABEL_MAX_CHARS 🔒
How long a link’s label may be before it is cut, as in Vega.
MAX_NOTE_IMAGES 🔒
How many of a note’s images a feed row shows.
MAX_NOTE_QUOTES
How many of the notes a note quotes are shown under it.
MAX_NOTE_VIDEOS 🔒
How many of a note’s videos a feed row gives room to.
MENTION_CHARS 🔒
How wide a mention is counted as, when counting what a note shows: about what a name takes, whoever it turns out to be.
QUOTE_DEPTH
How many notes deep quoting is shown: a note in a note in the note of a row, and no further. A note quoted deeper than that shows as a link: quoting has no end of its own.
REFERENCE_CHARS 🔒
How many characters of a note1…/naddr1… stand for the whole of it.
VIDEO_EXTENSIONS 🔒
The file extensions of the videos that are played in their row: files of pictures and sound, whatever is in them. Whether this machine can decode one is found out when it is played.

Functions§

has_extension 🔒
Whether the path of url ends in one of extensions.
imeta
What one NIP-92 imeta tag says, and of which address. None if it is not such a tag, or names no address.
inline
Every piece of segments that stands in a line of text: those in the cells of its tables too, each where it stands.
is_image 🔒
Whether url is a picture this client can fetch and show: an https address (nothing else is fetched) whose path ends like a picture’s.
is_video 🔒
Whether url is a video this client can fetch and play: an https address (nothing else is fetched) whose path ends like a video’s, that the note calls one (said), or that is a YouTube video’s.
labelled 🔒
What stands for a link the note gives a label of its own: the label, and after it where the link goes, unless the label says so itself. A label can say anything, and a click on it opens the address: which site that is on is not left to the label. With no label, the address made short, as for any link.
link_label 🔒
The text that stands for a link: its host and path, without the scheme, the query or a leading www., cut if it is still long.
may_be_page 🔒
Whether url may be a web page that can be asked what it says of itself: an https address (nothing else is fetched) whose path doesn’t end like a file’s.
named 🔒
What the nostr: URI uri stands for.
parse
Parse a note’s content, cutting its text at max_chars characters of what it shows. Of a note that is cut, all of the text is kept as well.
parse_attached
As parse, of a note that says attached of what it links to.
parse_dimensions 🔒
What an imeta tag’s dim field says: "1920x1080".
parse_up_to 🔒
content, with at most max_chars characters of its text, and whether there was more.
quote 🔒
The note id as one quoted, written by author and to be found at relay, as far as its address says.
short_reference 🔒
The first characters of a bech32 address, standing for all of it.