Changeset cd6a008 in Klonkt for src/services


Ignore:
Timestamp:
06/27/2026 12:16:21 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
00a2bcd
Parents:
ace5a9b
Message:

fix(fedi): preserve newlines when federating to Mastodon

Klonkt renders post content with white-space:pre-wrap, so raw \n are line breaks on the
site, but Mastodon collapses whitespace and dropped them (a poem arrived as one block).
buildNote now converts newlines to <br> for the federated copy. Content authored with
shift+enter already uses <br> (no \n) → no-op there.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    race5a9b rcd6a008  
    223223    body += `<p>🎵 ${lbl ? `<strong>${lbl}</strong> — ` : ''}<a href="${listenHref}">listen on ${esc(site.title || 'the site')}</a></p>`;
    224224  }
     225  // Klonkt renders post content with white-space:pre-wrap, so raw newlines ARE line
     226  // breaks on the site. Mastodon (plain HTML) collapses whitespace and would drop them,
     227  // so convert newlines to <br> for the federated copy (content already made with
     228  // shift+enter uses <br> and has no \n → this is a no-op there).
     229  body = body.replace(/\r?\n/g, '<br>');
    225230  const seen = new Set();
    226231  const attachment = urls.filter(Boolean)
Note: See TracChangeset for help on using the changeset viewer.