lorem-ipsum-generator について
lorem-ipsum-generator は、モックアップやワイヤーフレーム、テスト向けのプレースホルダーテキストを生成する Python ツールとコマンドラインプログラムです。複数の文体、長さ指定、HTML 出力、テンプレートへの挿入に対応します。
主な機能
- 01段落、文、単語、リストの生成
- 02出力の長さ指定
- 03HTML テキストの生成
- 04別のテキストスタイルの選択
- 05プレースホルダーでテンプレートを埋める
活用シーン
- 01モックアップやワイヤーフレームに仮文言を追加
- 02ページレイアウト用の HTML コンテンツを生成
- 03サンプル記事やテストデータを作成
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ dkyazzentwatwa/ chatgpt-skills --skill lorem-ipsum-generatorインストール後、Claude Code で/lorem-ipsum-generatorを入力して読み込まれたか確認します。
同梱ファイルscripts/lorem_gen.pyscripts/requirements.txt
詳細
Lorem Ipsum 生成器
モックアップ、ワイヤーフレーム、テスト用のプレースホルダーテキストを生成します。
特徴
- 定番の Lorem:従来の Lorem Ipsum テキスト
- 複数の形式:段落、文、単語、リスト
- 長さのカスタマイズ:単語数、文数、段落数を指定できます
- HTML 出力:HTML タグ付きで生成します
- 別のソース:ヒップスター風、ベーコン風、企業風の Ipsum
- テンプレート:プレースホルダーテキストをテンプレートに挿入します
クイックスタート
from lorem_gen import LoremGenerator
gen = LoremGenerator()
# Generate paragraphs
text = gen.paragraphs(3)
print(text)
# Generate sentences
sentences = gen.sentences(5)
print(sentences)
# Generate words
words = gen.words(50)
print(words)
CLI の使用方法
# Generate 3 paragraphs
python lorem_gen.py --paragraphs 3
# Generate 5 sentences
python lorem_gen.py --sentences 5
# Generate 100 words
python lorem_gen.py --words 100
# HTML output
python lorem_gen.py --paragraphs 3 --html
# Generate bullet list
python lorem_gen.py --list 5
# Generate with specific word count per paragraph
python lorem_gen.py --paragraphs 3 --words-per 50
# Alternative style
python lorem_gen.py --paragraphs 3 --style hipster
# Save to file
python lorem_gen.py --paragraphs 5 --output placeholder.txt
API リファレンス
LoremGenerator クラス
class LoremGenerator:
def __init__(self, style: str = "classic")
# Basic generation
def paragraphs(self, count: int = 3, words_per: int = None) -> str
def sentences(self, count: int = 5) -> str
def words(self, count: int = 50) -> str
# Structured output
def list_items(self, count: int = 5, ordered: bool = False) -> str
def heading(self, level: int = 1) -> str
def title(self, words: int = 4) -> str
# HTML output
def html_paragraphs(self, count: int = 3) -> str
def html_list(self, count: int = 5, ordered: bool = False) -> str
def html_article(self, sections: int = 3) -> str
# Templates
def fill_template(self, template: str) -> str
# Configuration
def set_style(self, style: str) -> 'LoremGenerator'
出力形式
段落
text = gen.paragraphs(2)
# Output:
# Lorem ipsum dolor sit amet, consectetur adipiscing 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.
文
text = gen.sentences(3)
# Output:
# Lorem ipsum dolor sit amet. Consectetur adipiscing elit. Sed do eiusmod tempor.
単語
text = gen.words(10)
# Output:
# Lorem ipsum dolor sit amet consectetur adipiscing elit sed do
リスト
# Unordered list
text = gen.list_items(3)
# - Lorem ipsum dolor sit amet
# - Consectetur adipiscing elit
# - Sed do eiusmod tempor
# Ordered list
text = gen.list_items(3, ordered=True)
# 1. Lorem ipsum dolor sit amet
# 2. Consectetur adipiscing elit
# 3. Sed do eiusmod tempor
HTML 出力
HTML 段落
html = gen.html_paragraphs(2)
# <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
# <p>Sed do eiusmod tempor incididunt ut labore.</p>
HTML リスト
html = gen.html_list(3, ordered=False)
# <ul>
# <li>Lorem ipsum dolor sit amet</li>
# <li>Consectetur adipiscing elit</li>
# <li>Sed do eiusmod tempor</li>
# </ul>
HTML 記事
html = gen.html_article(sections=2)
# <article>
# <h1>Lorem Ipsum Dolor</h1>
# <p>Lorem ipsum dolor sit amet...</p>
# <h2>Consectetur Adipiscing</h2>
# <p>Ut enim ad minim veniam...</p>
# </article>
テキストのスタイル
定番の Lorem Ipsum
従来のラテン語のプレースホルダーテキスト:
gen = LoremGenerator(style="classic")
ヒップスター風 Ipsum
流行を取り入れた現代的な語彙:
gen = LoremGenerator(style="hipster")
# "Artisan cold-pressed pour-over, sustainable raw denim..."
企業風 Ipsum
ビジネス用語:
gen = LoremGenerator(style="corporate")
# "Leverage agile frameworks to provide robust synopsis..."
技術風 Ipsum
テクノロジーをテーマにしたテキスト:
gen = LoremGenerator(style="tech")
# "API endpoints serverless microservices kubernetes..."
テンプレート
プレースホルダーテキストをテンプレートに挿入します:
template = """
# {{title}}
{{paragraph}}
## Features
{{list:5}}
## Details
{{paragraph}}
{{paragraph}}
"""
result = gen.fill_template(template)
テンプレートのプレースホルダー
| プレースホルダー | 出力 |
|---|---|
{{title}} | 3~5語のタイトル |
{{heading}} | セクションの見出し |
{{paragraph}} | 1つの段落 |
{{sentence}} | 1つの文 |
{{words:N}} | N 個の単語 |
{{list:N}} | N 個のリスト項目 |
{{name}} | ランダムな名前 |
{{email}} | ランダムなメールアドレス |
{{date}} | ランダムな日付 |
単語数の指定
段落ごとの単語数を正確に指定します:
# Each paragraph will have exactly 50 words
text = gen.paragraphs(3, words_per=50)
# Generate exactly 200 words
text = gen.words(200)
ワークフローの例
モックアップ用テキストの生成
gen = LoremGenerator()
# Generate blog post mockup
title = gen.title(words=6)
intro = gen.paragraphs(1, words_per=100)
body = gen.paragraphs(3, words_per=150)
conclusion = gen.paragraphs(1, words_per=75)
print(f"# {title}\n\n{intro}\n\n{body}\n\n{conclusion}")
HTML ページのコンテンツ
gen = LoremGenerator()
html = f"""
<!DOCTYPE html>
<html>
<body>
<header>
<h1>{gen.title()}</h1>
</header>
<main>
{gen.html_paragraphs(3)}
<h2>Features</h2>
{gen.html_list(5)}
{gen.html_paragraphs(2)}
</main>
</body>
</html>
"""
テストデータの生成
gen = LoremGenerator()
# Generate test articles
articles = []
for i in range(10):
articles.append({
"title": gen.title(),
"excerpt": gen.sentences(2),
"body": gen.paragraphs(5),
"tags": gen.words(3).split()
})
依存関係
- faker>=22.0.0(オプション。より充実したフェイクデータ用)
コメント
Markdown 対応