- Notifications
You must be signed in to change notification settings - Fork43
Generate lorem ipsum placeholder text
License
knicklabs/lorem-ipsum.js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
🎉Celebrating 10 years oflorem-ipsum 🎉
lorem-ipsum is a JavaScript module for generating passages of loremipsum text. Lorem ipsum text is commonly used as placeholder text inpublishing, graphic design, and web development.
lorem-ipsum is compatible with the browser, Node.JS, and React Native.
THIS README IS FOR VERSION 2. SWITCH TO1-STABLE BRANCH FOR THEVERSION 1 DOCUMENTATION.
IF YOU NEED COMPATIBILITY WITH OLDER VERSIONS OF NODEJS, PLEASE USE V1.0.6 WHICH ISCOMPATIBLE BACK TO NODE 0.4.npm i lorem-ipsum@1.0.6
npm i lorem-ipsumThe class is the recommended way to uselorem-ipsum since version 2.It makes it simpler to generate text using the same options.
import{LoremIpsum}from"lorem-ipsum";// const LoremIpsum = require("lorem-ipsum").LoremIpsum;constlorem=newLoremIpsum({sentencesPerParagraph:{max:8,min:4},wordsPerSentence:{max:16,min:4}});lorem.generateWords(1);lorem.generateSentences(5);lorem.generateParagraphs(7);
lorem-ipsum version 2 exports a function that is backwards-compatible with the default function exported bylorem-ipsum version
- Users of version 1 should be able to upgrade to version 2 withoutany issue; they can just continue using this library as they did before.
import{loremIpsum}from"lorem-ipsum";// const loremIpsum = require("lorem-ipsum").loremIpsum;loremIpsum();// generates one sentence
Like before, you can pass in a number of options to customize the output.The example below shows the default options.
import{loremIpsum}from"lorem-ipsum";loremIpsum({count:1,// Number of "words", "sentences", or "paragraphs"format:"plain",// "plain" or "html"paragraphLowerBound:3,// Min. number of sentences per paragraph.paragraphUpperBound:7,// Max. number of sentences per paragarph.random:Math.random,// A PRNG functionsentenceLowerBound:5,// Min. number of words per sentence.sentenceUpperBound:15,// Max. number of words per sentence.suffix:"\n",// Line ending, defaults to "\n" or "\r\n" (win32)units:"sentences",// paragraph(s), "sentence(s)", or "word(s)"words:["ad", ...]// Array of words to draw from})
lorem-ipsum includes a command line interface (CLI) program for generatingpassages of lorem ipsum text directly from your terminal. This CLI programis compatible with Mac OSX, Windows, and Linux. On Linux you will need toinstall xclip. On Ubuntu:apt-get install xclip.
Simply install the module globally to take advantage of this feature.
npm i -g lorem-ipsumExecute the statementlorem-ipsum [count] [units] from your terminal togenerate a passage of lorem ipsum text. You can additional arguments tothe program.
lorem-ipsum --version# Displays the version numberlorem-ipsum --help# Displays the help documentationlorem-ipsum 1 word# Prints one wordlorem-ipsum 2 words# Prints two wordslorem-ipsum 1 sentence# Prints one sentencelorem-ipsum 2 sentences# Prints two sentenceslorem-ipsum 1 paragraph# Prints one paragraphlorem-ipsum 2 paragraphs# Prints two paragraphslorem-ipsum 2 paragraphs --copy# Prints two pargraphs and copies it to your clipboardlorem-ipsum 2 paragraphs --format html# Prints two paragraphs in HTML formatlorem-ipsum 2 paragraphs --format html --copy# Prints two paragraphs in HTML format and copies it to your clipboard.Uprading from version 1.x? The--count and--units options have beendropped in favor of the natural language interface shown in the examplesabove.
Copyright (c) 2012-2022 Nickolas Kenyeresnickolas@knicklabs.com
Permission to use, copy, modify, and/or distribute this software for anypurpose with or without fee is hereby granted, provided that the abovecopyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
About
Generate lorem ipsum placeholder text
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.