Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generate lorem ipsum placeholder text

License

NotificationsYou must be signed in to change notification settings

knicklabs/lorem-ipsum.js

Codacy BadgeCoverage Statusnpm versionnodenpm

Overview

🎉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.

Important Notes

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

Installation

npm i lorem-ipsum

Using the Class

The 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);

Using the Function

lorem-ipsum version 2 exports a function that is backwards-compatible with the default function exported bylorem-ipsum version

  1. 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})

Using the CLI

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-ipsum

Execute 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.

License

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.

Packages

No packages published

Contributors14


[8]ページ先頭

©2009-2025 Movatter.jp