chrissimpkins / lorem

A dummy text generator and text replacement tool that embeds text in existing files, creates new text files, and writes text to the standard out stream. Will write up to 1 million paragraphs (and can be recompiled with this restriction modified)
http://j.mp/LOREM
MIT License
1 stars 0 forks source link

lorem

A dummy text generator and text replacement application that creates new text files, embeds text in existing files, or prints it to the standard out stream (so that you can pipe it to whatever you'd like).

http://j.mp/LOREM

Updates

Use your own dummy text (or any replacement text) by including the insertion text file path after the -t option. More information below.

Installation

Open your terminal in the main source directory and then:

./configure
make
sudo make install

Use Examples

Create a New File with Dummy Text

Say you want to create a new file named 'eg.txt' with 5 paragraphs of dummy text. Use the following command:

lorem -n 5 -o eg.txt

Append Dummy Text to an Existing Text File

You have a file named 'eg.txt' and you would like to append 10 paragraphs of dummy text to it. Use the following command:

lorem -a -n 10 -o eg.txt

Insert Dummy Text into a Specific Location in an Existing Text File

Say you have the following html file named 'eg.html':

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lorem example</title>
<link rel="stylesheet" href="https://github.com/chrissimpkins/lorem/blob/master/css/main.css" type="text/css" />
</head>
<body id="index" class="home">
<p class="main_paragraph">

</p>
</body>
</html>

Add the delimiter <lorem> to the file like this (it's between the p tags):

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lorem example</title>
<link rel="stylesheet" href="https://github.com/chrissimpkins/lorem/blob/master/css/main.css" type="text/css" />
</head>
<body id="index" class="home">
<p class="main_paragraph">
<lorem>
</p>
</body>
</html>

Then run the following to insert a paragraph of lorem text at the site of the delimiter:

lorem -r -i eg.html

And here is what you get:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lorem example</title>
<link rel="stylesheet" href="https://github.com/chrissimpkins/lorem/blob/master/css/main.css" type="text/css" />
</head>
<body id="index" class="home">
<p class="main_paragraph">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</body>
</html>

Rinse and repeat as desired. Use the -n option to insert more than one paragraph.

Insert Tags Before and After Each Paragraph

If you want to wrap each paragraph with it's own set of tags, you can enter them with the -b and -e options (for begin and end). Make sure that you use quotes around special characters on the command line. This includes the < and > symbols.

Here is an example of how you would make five paragraphs of dummy text wrapped with a p tag that has a class.

The file before the insert with the <lorem> delimiter included between the body tags:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lorem example</title>
<link rel="stylesheet" href="https://github.com/chrissimpkins/lorem/blob/master/css/main.css" type="text/css" />
</head>
<body id="index" class="home">
<lorem>
</body>
</html>

Enter the following command:

lorem -r -n 5 -b "<p class='coolclass'>" -e "</p>"

And here is what you get:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lorem example</title>
<link rel="stylesheet" href="https://github.com/chrissimpkins/lorem/blob/master/css/main.css" type="text/css" />
</head>
<body id="index" class="home">
<p class='coolclass'>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class='coolclass'>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class='coolclass'>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class='coolclass'>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class='coolclass'>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</body>
</html>

Ta da!

Bring Your Own Text for Replacements

If you want to use your own text in replacements, include the file path to the file that includes the text that you want to insert into another file after the -t option.

Here is an example of how to include 10 blocks of your own text that is included in a file on the path path/to/replacement.txt and is inserted in the location of the <lorem> delimiter of a file on the path path/to/insertfile.txt

lorem -r -n 10 -i path/to/insertfile.txt -t path/to/replacement.txt

Voila!

Pipe Dummy Text to Another Application

lorem will write up to one million paragraphs of dummy text to the standard out stream. Pipe it to whatever you like.

lorem -s -n 1000000 | wc -c

Increase the Text Limit

If you need more text, modify the paragraph limit in the lorem.h header file. Change the integer in the line:

#define PARA_LIMIT (int)1000000

to whatever you'd like and then re-compile and install the application using the instructions above. Be aware of the storage limitations on your machine if you set this to a massive number... There are no protections in place for memory limits.

Help

Enter the following for help:

lorem -h

All of the available options are detailed.

License

The MIT License (MIT)

Copyright (c) 2013 Christopher Simpkins

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.