Utilities
Helper functions for working with the API's text format and other conventions.
The SDK ships utility functions for common tasks that sit outside the
core request/response flow. Import them from @betterfans/link-sdk/utils.
Text format
The API does not accept plaintext for message and post bodies. The
text field expects a specific subset of HTML wrapped in a <p> tag.
Accepted tags
| Tag | Purpose |
|---|---|
<p> | Required wrapper — all text must be inside a single <p> |
<br> | Line breaks (newlines must be expressed as <br>) |
<strong> | Bold text |
<em> | Italic text |
<span class="m-editor-fs__lg"> | Large heading |
<span class="m-editor-fs__l"> | Medium heading |
<span class="m-editor-fc__blue-1"> | Accent colour (used with bold italic) |
Any other HTML tags or attributes are stripped by the platform.
Example
The API expects text like this:
<p><strong>Welcome!</strong><br>Thanks for subscribing</p>Not this:
Welcome!
Thanks for subscribingmarkdownToHtml
To avoid constructing HTML manually, the SDK provides a
markdownToHtml utility that converts familiar markdown syntax into
the accepted format.
import { markdownToHtml } from "@betterfans/link-sdk/utils"Supported syntax
| Markdown | Result |
|---|---|
**bold** | <strong>bold</strong> |
*italic* | <em>italic</em> |
***bold italic*** | Bold italic with accent colour |
# Heading | Large heading |
## Heading | Large heading |
### Heading | Medium heading |
| Newlines | <br> |
Usage
import { markdownToHtml } from "@betterfans/link-sdk/utils"
const text = markdownToHtml("**Welcome!**\nThanks for subscribing")
// → <p><strong>Welcome!</strong><br>Thanks for subscribing</p>
await account.request("POST /chats/:id/messages", {
pathParams: { id: "98765" },
body: { text },
})If you pass raw plaintext without wrapping it in the expected HTML, the message will still send but formatting like newlines, bold, and headings won't render correctly in the app.