Trim leading whitespace-only lines (#7555)

This commit is contained in:
dan
2025-01-23 12:02:50 +00:00
committed by GitHub
parent 53d4854ee6
commit 16abe45bb2
+6 -1
View File
@@ -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)