views:

133

answers:

2

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.

A: 

Sure, most of the stuff out there is geared for use in browsers, but essentially anything where functions are added to the String prototype should be helpful to you. Have a look at some of the functions here:

http://code.delacap.com/p/js-methods/docs/string.html

Then you can add your own:

String.prototype.myFunc = function(){ 
    //...
};

"someStr".myfunc(); 
Jage
I don't see how this is helpful or even applicable to the OP.
Justin Johnson
A: 

I haven't heard on any since what you're attempting is probably no too popular.

You may have to build your own function based on JavaScript's built-in string functions.

Diodeus