Skip to content

Commit

Permalink
Trim leading whitespace-only lines (#7555)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Jan 23, 2025
1 parent 53d4854 commit 16abe45
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ export async function post(
}

async function resolveRT(agent: BskyAgent, richtext: RichText) {
let rt = new RichText({text: richtext.text.trimEnd()}, {cleanNewlines: true})
const trimmedText = richtext.text
// Trim leading whitespace-only lines (but don't break ASCII art).
.replace(/^(\s*\n)+/, '')
// Trim any trailing whitespace.
.trimEnd()
let rt = new RichText({text: trimmedText}, {cleanNewlines: true})
await rt.detectFacets(agent)

rt = shortenLinks(rt)
Expand Down

0 comments on commit 16abe45

Please sign in to comment.