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).
Types ¶
This section is empty.