Documentation
¶
Overview ¶
Package textplain turns a markdown-flavoured string into the plain text a reader of the rendered markdown would see, on one line. It is THE title rule: every surface that shows a title (cards, lists, detail headings, document <title>s, push notifications, attention, recents, focus titles, chat session titles, mirrored window titles) shows Title(s), never s.
🔴 ONE RULE, ONE PLACE. Before this package there were three strippers that disagreed: ui.markdownPlain (removed every ` * _ # > anywhere, so it mangled snake_case_names, "#123" and "C#" and left [text](url) links, ~~strike~~ and HTML tags untouched), api.notificationText (unwrapped links but stripped intraword underscores), and focus.oneLine (deleted every * ` # from a focus title BEFORE IT WAS STORED). The first two now call Title; the third strips no markdown at all any more, because it writes storage (see below). A title therefore reads the same on the card, in its <title> and on the phone, and TestTheTitleSinkLedger (internal/textplain) fails when a display sink reads a title without it.
🔴 APPLIED AT RENDER/EMIT TIME, NEVER TO STORED DATA. Titles are stored as the author wrote them; an edit form shows them raw. Stripping on the way out keeps the transformation reversible: a rule change re-renders every title, a stripped store could never be un-stripped.
It is NOT a markdown parser. It is a set of conservative rewrites chosen so that ordinary non-markdown text survives unchanged: snake_case_names, a*b math, file_paths/with_underscores, C# and F#, "#123" issue references, emails, generic types like List<String>, and a bare URL that is the whole title. Each of those is a must-not-change case in textplain_test.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Title ¶
Title returns s as the one-line plain text a reader of its rendered markdown would see: links become their text, images their alt text, emphasis, strike and code markers are removed, heading/list/blockquote/table markers removed, HTML tags removed, entities decoded once, whitespace collapsed. Fenced code blocks are dropped whole (a title has no use for a code block, and a body snippet built from this reads as prose).
func TitleKeeping ¶ added in v0.124.0
TitleKeeping is Title over s except every occurrence of keep, which is kept VERBATIM: a machine identifier inside a human title — a mirrored window's tmux target (mirror.WhereTarget), whose session name may be "_scratch_", "*dev*" or "a`b`c" and must reach the reader exactly, since they type it. The text around it is plained piece by piece (a piece's edge whitespace kept as one space, so "mango:1 · " still joins its target), and the whole is trimmed. keep "" is Title.
It is the title rule (TestTheTitleSinkLedger counts it as one); the caller still escapes for its surface (HTML on a page, one line on a push).
Types ¶
This section is empty.