I am trying to write a script to automate a rather long and painful process I am required to do at work.
Scenario:
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:
From my limited JavaScript knowledge, I am thinking that I need to set <p> tags around each 4-line “paragraph.” Then I should be able to write a script that would select the <p> tag, extract the data I need, write it to the table, and repeat the process for the next <p> tag.
I know there are online options that will do this for me (textfixer.com, for example), but my system is not connected to the internet, and for security reasons, it will never be. This means I can not use PHP (which I know better) or any other server-side processing. I am hoping this can be done through JavaScript, so I can process it through a browser. This is a Windows machine so if there is another way to do it, I am open to ideas.
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:
Example: http://jsfiddle.net/2uMaK/