safeHtml
type GuidedReviewSection = object;
One prompt/answer pair from Audible's guided questionnaire review body.
answer: string;
question?: string;
type: string;
function decodeHtmlEntities(raw): string;
Decodes HTML entities (’, ’, …) into Unicode text.
Uses a pure string decoder (no innerHTML / DOM text round-trip) so the
result is never sourced from reinterpreted DOM HTML.
| Parameter | Type | Description |
|---|---|---|
raw |
string |
Text that may contain entities. |
string
Decoded string. Unknown named entities are left unchanged; numeric
entities use String.fromCodePoint when valid.
function descriptionPlainText(raw): string;
Builds a plain-text teaser for cards (HTML stripped).
| Parameter | Type | Description |
|---|---|---|
raw |
string | null | undefined |
Optional HTML or guided-review JSON body. |
string
Single-line plain text.
function escapeHtml(raw): string;
Escapes plain text for HTML embedding.
| Parameter | Type | Description |
|---|---|---|
raw |
string |
Untrusted text. |
string
Entity-escaped string safe for HTML text nodes.
function parseGuidedReviewBody(raw): GuidedReviewSection[] | null;
Best-effort parse of Audible guided review JSON.
| Parameter | Type | Description |
|---|---|---|
raw |
string |
Review body that may be a JSON array of {type,question,answer}. |
GuidedReviewSection[] | null
Parsed sections, or null when the body is not that schema.
function prepareDescriptionHtml(raw): string;
Prepares description HTML for safe rendering.
Plain text is escaped; markup is reduced to p / br / b/strong /
i/em / lists (no attributes). Guided JSON bodies return empty string
(render structured React instead).
Uses sanitizeMarkupToAllowlist (string token walk). See the module
comment for why we avoid DOMParser / innerHTML and when to reconsider.
| Parameter | Type | Description |
|---|---|---|
raw |
string |
Store or review description. |
string
Sanitized HTML fragment.
Generated from ui/src/lib at main · View as Markdown