Browse the docs

cleanText

Fixes text pasted from a web page or PDF: straight quotes and dashes, plain spaces, no hidden characters.

Details #

cleanText(text) is the "pasted from a web page or PDF" fix. It makes curly quotes straight, turns en dashes, em dashes and minus signs into - and an ellipsis into ..., turns no-break and other unusual spaces into plain spaces, removes zero-width characters, soft hyphens and control characters, changes line endings to \n, and trims trailing spaces on each line. Also the cleanText op of Transform text.

Parameters #

Takes 1 argument. {{ cleanText(text) }}

Examples #

cleanText("“Hello” — it’s fine…")
→ "Hello" - it's fine...

Gotchas #

  • Em dashes become a plain -, with the spaces around them kept as they were.

  • Tabs and line breaks are kept.