chenglou/pretext ? reverse-engineered prompt
Reverse engineered prompt
I want to build a JavaScript library for handling complex text layout on the web. It's always a pain to figure out how tall a block of text will be without actually rendering it to the DOM, which is slow and causes content to jump around as it loads.
This library should solve that. It should be able to take a string of text, a font style, and a container width, and then quickly calculate the final height and number of lines without any DOM measurements. It needs to be very accurate and support all kinds of languages and emoji.
It should have two main functions. First, just give me the height for a given width. Second, give me the actual text for each wrapped line, so I can render them myself in a custom way, like on a <canvas> or in an SVG. This would be great for UIs that need to flow text around images or other elements. Also include a small helper for handling inline rich-text elements like tags or mentions that shouldn't break across lines. Use TypeScript for this.
Are you gonna build this?
make sure you review the code using coderabbit