Resolve facets on list descriptions (#2485)

* feat: add strict/loose link mapping

* feat: resolve facets on list description
This commit is contained in:
Mary 2024-01-24 01:39:13 +07:00 committed by GitHub
parent 1828bc9755
commit abac959d03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 110 additions and 24 deletions

View file

@ -1,7 +1,7 @@
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
import {linkRequiresWarning} from './url-helpers'
export function richTextToString(rt: RichText): string {
export function richTextToString(rt: RichText, loose: boolean): string {
const {text, facets} = rt
if (!facets?.length) {
@ -19,7 +19,7 @@ export function richTextToString(rt: RichText): string {
const requiresWarning = linkRequiresWarning(href, text)
result += !requiresWarning ? href : `[${text}](${href})`
result += !requiresWarning ? href : loose ? `[${text}](${href})` : text
} else {
result += segment.text
}