summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/text/lorem.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-10-27 19:04:55 +0100
committerGitHub <noreply@github.com>2024-10-27 18:04:55 +0000
commitbe7cfc85d08c545abfac08098b7b33b4bd71f37e (patch)
treef4137fa2aaa57babae1f7603a9b2ed7e688f43d8 /crates/typst-library/src/text/lorem.rs
parentb8034a343831e8609aec2ec81eb7eeda57aa5d81 (diff)
Split out four new crates (#5302)
Diffstat (limited to 'crates/typst-library/src/text/lorem.rs')
-rw-r--r--crates/typst-library/src/text/lorem.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/typst-library/src/text/lorem.rs b/crates/typst-library/src/text/lorem.rs
new file mode 100644
index 00000000..5d01a550
--- /dev/null
+++ b/crates/typst-library/src/text/lorem.rs
@@ -0,0 +1,24 @@
+use crate::foundations::{func, Str};
+
+/// Creates blind text.
+///
+/// This function yields a Latin-like _Lorem Ipsum_ blind text with the given
+/// number of words. The sequence of words generated by the function is always
+/// the same but randomly chosen. As usual for blind texts, it does not make any
+/// sense. Use it as a placeholder to try layouts.
+///
+/// # Example
+/// ```example
+/// = Blind Text
+/// #lorem(30)
+///
+/// = More Blind Text
+/// #lorem(15)
+/// ```
+#[func(keywords = ["Blind Text"])]
+pub fn lorem(
+ /// The length of the blind text in words.
+ words: usize,
+) -> Str {
+ lipsum::lipsum(words).replace("--", "–").into()
+}