I am trying to write a script to automate a rather long and painful process I am required to do at work.
In short, I am given a text document that has 4 lines of text and two line breaks, and this format repeats for 5 to 8 pages. I then have to extract 6 pieces of information from each "paragraph" and type them out into a table in another document.
Since the output I get is formatted (including the fields that I extract data from), I would like to be able to paste my text into a textbox, click convert, and have it return the results I need and list them in a table.
Where I need help/advise:
You could split the document on a series of three line breaks (one to account for the end of line break, two for the empty lines), and then rejoin them with paragraph tags:
// pull the document out var doc = $("#my-document").val(); // split on double line breaks // note that we actually split on triple to account for the trailing // line break at the end of a paragraph var parts = doc.split("\n\n\n"); // rejoin with paragraph tags doc = parts.join("</p><p>"); // wrap the entire thing in open/close paragraphs doc = "<p>" + doc + "</p>"; // and stick it in the output $("#output").html(doc);