| … | … | @@ -15,6 +15,8 @@ |
| 15 | 15 | // goes. Dropping one field is recoverable; publishing half a sentence as though it were the whole |
| 16 | 16 | // one is not. |
| 17 | 17 | |
| 18 | import { strip } from 'favela-markdown/lib/strip.js' |
| 19 | |
| 18 | 20 | // app.bsky.actor.profile: displayName maxGraphemes 64, description maxGraphemes 256. |
| 19 | 21 | export const MAX_NAME_GRAPHEMES = 64 |
| 20 | 22 | export const MAX_DESCRIPTION_GRAPHEMES = 256 |
| … | … | @@ -27,6 +29,17 @@ export const BSKY_IMAGE_TYPES = ['image/png', 'image/jpeg'] |
| 27 | 29 | |
| 28 | 30 | const graphemesOf = (s) => [...String(s || '')].length |
| 29 | 31 | |
| 32 | // TOTAL, like everything else here: a bio that will not parse degrades to its own text rather than |
| 33 | // taking the profile down with it. |
| 34 | function plainText (md) { |
| 35 | try { |
| 36 | const r = strip(md) |
| 37 | return ((r && r.text) || '').trim() |
| 38 | } catch { |
| 39 | return String(md || '').trim() |
| 40 | } |
| 41 | } |
| 42 | |
| 30 | 43 | /** |
| 31 | 44 | * planProfile({ name, bio, avatar, banner }) -> { project, record, images, losses } |
| 32 | 45 | * |
| … | … | @@ -49,7 +62,11 @@ export function planProfile ({ name = null, bio = null, avatar = null, banner = |
| 49 | 62 | } |
| 50 | 63 | } |
| 51 | 64 | |
| 52 | | const d = typeof bio === 'string' ? bio.trim() : '' |
| 65 | // ⛔ STRIPPED, because a bsky description is PLAIN TEXT. The bio is markdown — that is the whole |
| 66 | // premise of favela-markdown — and handing it over raw publishes `the **dev** box` with the |
| 67 | // asterisks showing. Measured on the live profile before this: bsky's own AppView rendered them |
| 68 | // literally. `strip` is the same projection every other plain-text destination already uses. |
| 69 | const d = typeof bio === 'string' ? plainText(bio) : '' |
| 53 | 70 | if (d) { |
| 54 | 71 | if (graphemesOf(d) > MAX_DESCRIPTION_GRAPHEMES) { |
| 55 | 72 | losses.push('description omitted — ' + graphemesOf(d) + ' graphemes against a limit of ' + MAX_DESCRIPTION_GRAPHEMES) |