javascript normalize whitespace and other plain-text formatting routines

Posted by dreftymac on Stack Overflow See other posts from Stack Overflow or by dreftymac
Published on 2010-03-12T19:35:36Z Indexed on 2010/03/12 19:37 UTC
Read the original article Hit count: 363

Filed under:
|
|
|
|

Background:

The language is JavaScript. The goal is to find a library or pre-existing code to do low-level plain-text formatting.

I can write it myself, but why re-invent the wheel. The issue is: it is tough to determine if a "wheel" is out there, since any search for JavaScript libraries pulls up an ocean of HTML-centric stuff. I am not interested in HTML necessarily, just text.

Example:

I need a JavaScript function that changes this:

BEFORE:

nisi ut aliquip | ex ea commodo consequat duis |aute irure dolor in
esse cillum dolore | eu fugiat nulla pariatur |excepteur sint occa
in culpa qui | officia deserunt mollit anim id |est laborum

... into this ...

AFTER:

nisi ut aliquip    | ex ea commodo consequat duis    | aute irure dolor in      
esse cillum dolore | eu fugiat nulla pariatur        | excepteur sint occa
in culpa qui       | officia deserunt mollit anim id | est laborum              

Question:

Does it exist, a JavaScript library that is non-html-web-development-centric that has functions for normalizing spaces in delimited plain text, justifying and spacing plain text?

Rationale:

Investigating JavaScript for use in a programmer's text editor.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about text-editor