Lorem ipsum
Placeholder text for mock-ups, seed data and tests: Lorem ipsum words, sentences, paragraphs and titles, the same every time for a given seed.
Version 1.0.0 · 4 functions · 3 crates
Functions
What use lorem.qwer gives a program, with the types Quillo sees. To take only some, or under other names: use lorem_words, lorem_sentences from lorem (Quillo 0.6).
lorem_words(n: int) → strn words of the classic text, starting "Lorem ipsum dolor sit amet", with its punctuation; up to 100,000.
lorem_sentences(n: int, seed: int) → strn sentences of 6 to 16 words each, joined by spaces; seed 0 gives other ones each time, any other seed the same ones each time. Up to 10,000.
lorem_paragraphs(n: int, seed: int) → listn paragraphs of 3 to 7 sentences, as a list; seed as for lorem_sentences. Up to 1,000.
lorem_title(seed: int) → strA title of 2 to 5 words in Title Case, such as "Fugiat Dolore Exercitation"; seed as above.
Get it
$ quillo install lorem # lorem.qwer into this folder$ quillo install lorem --example # and its example, lorem.qweOr with curl:
$ curl -O https://quillolang.org/plugins/files/lorem.qwer$ curl -O https://quillolang.org/plugins/files/lorem.qweThen, in your program, all of it or only what you call:
use lorem.qweruse lorem_words, lorem_sentences from lorem // Quillo 0.6: only theseIt uses these crates, which cargo fetches the first time the plugin is built:
lipsum = "0.9"rand_chacha = "0.3"rand = { version = "0.8", default-features = false }Example
// Seed data for a blog mock-up: posts with titles and paragraphs, the same on every run.//// quillo run lorem.qwe then open http://localhost:8080/postsuse "lorem.qwer"route GET /posts = range(1, 4) | map((i) => { id: i, title: lorem_title(i), excerpt: lorem_sentences(1, i), body: lorem_paragraphs(2, i) })route GET /words ? { n: int = 8 } = { text: lorem_words(n) }route GET /page = <html> <body> <h1>{lorem_title(7)}</h1> {lorem_paragraphs(3, 7) | map((p) => <p>{p}</p>)} </body></html>$ quillo run lorem.qwe$ curl 'localhost:8080/words'$ curl 'localhost:8080/posts'Source
//! Placeholder text for mock-ups, seed data and tests: Lorem ipsum words, sentences, paragraphs and titles, the same every time for a given seed.//! version: 1.0.0//!//! [dependencies]//! lipsum = "0.9"//! rand_chacha = "0.3"//! rand = { version = "0.8", default-features = false }use rand::SeedableRng;use rand_chacha::ChaCha8Rng;fn rng(seed: i64) -> ChaCha8Rng { if seed == 0 { let t = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(1, |d| d.as_nanos() as u64); ChaCha8Rng::seed_from_u64(t) } else { ChaCha8Rng::seed_from_u64(seed as u64) }}/// `n` words of the classic text, starting "Lorem ipsum dolor sit amet", with its punctuation; up to 100,000.pub fn lorem_words(n: i64) -> String { lipsum::lipsum(n.clamp(0, 100_000) as usize)}/// `n` sentences of 6 to 16 words each, joined by spaces; `seed` 0 gives other ones each time, any other seed the same ones each time. Up to 10,000.pub fn lorem_sentences(n: i64, seed: i64) -> String { use rand::Rng; let mut r = rng(seed); (0..n.clamp(0, 10_000)) .map(|_| { let k = r.gen_range(6..=16); let words = lipsum::lipsum_words_with_rng(&mut r, k); let mut s: String = words.trim_end_matches(|c: char| !c.is_alphanumeric()).to_string(); if let Some(f) = s.get(..1) { s = f.to_uppercase() + &s[1..]; } s + "." }) .collect::<Vec<_>>() .join(" ")}/// `n` paragraphs of 3 to 7 sentences, as a list; `seed` as for `lorem_sentences`. Up to 1,000.pub fn lorem_paragraphs(n: i64, seed: i64) -> Vec<String> { use rand::Rng; let mut r = rng(seed); (0..n.clamp(0, 1000)).map(|_| { let k = r.gen_range(3..=7); lorem_sentences(k, r.gen_range(1..i64::MAX)) }).collect()}/// A title of 2 to 5 words in Title Case, such as "Fugiat Dolore Exercitation"; `seed` as above.pub fn lorem_title(seed: i64) -> String { use rand::Rng; let mut r = rng(if seed == 0 { 0 } else { seed ^ 0x5DEE_CE66 }); let k = r.gen_range(2..=5); lipsum::lipsum_words_with_rng(&mut r, k) .split_whitespace() .map(|w| { let w: String = w.chars().filter(|c| c.is_alphanumeric()).collect(); let mut c = w.chars(); c.next().map_or(String::new(), |f| f.to_uppercase().collect::<String>() + c.as_str()) }) .filter(|w| !w.is_empty()) .collect::<Vec<_>>() .join(" ")}Related
case.qwer · 1.0.0Text in snake_case, camelCase, PascalCase, kebab-case, CONSTANT_CASE, Title Case and Sentence case: column names as API keys and labels.7 views · 8 downloadsChinese words chinese_segment.qwer · 1.0.0Chinese text split into words for search indexes and counts, with parts of speech, and written in pinyin with tones, tone numbers or initials for sorting and finding names.7 views · 7 downloadsEmoji emoji.qwer · 1.0.0Emoji for chat and comments: :shortcodes: turned into emoji and back, emoji found with their names, stripped from subjects, and searched by name for a picker.7 views · 8 downloadsFuzzy search fuzzy.qwer · 1.0.0Rank names against what someone typed, typos and all, edit distances, and did-you-mean.7 views · 8 downloadsHTML to text html_text.qwer · 1.0.0HTML as readable plain text for the text part of an email: headings, lists and tables laid out, links listed at the end, and one-line previews.7 views · 7 downloadsHumanize humanize.qwer · 1.0.0Durations, file sizes and relative times as people write them and back: 2h 30m, 1.5 GB, 2 GiB, 3 days ago, in 2 hours.7 views · 11 downloadsThread 0 posts
On Lorem ipsum: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.