Generating Placeholder Text - Specifying the Number of Paragraphs


#1

I was recently asked on Twitter if I knew a way of generating filler or placeholder text and I use Keyboard Maestro to do this usually.

My macro asks me how many paragraphs I want (usually 5) and then creates however many paragraphs I need - I only have 5 different paragraphs in there because that's enough for me that the text doesn't look regular.

To create any number of paragraphs I'm using a For Each together with a modulo calculation, I prefer to have an extra line break between each paragraph, hence formatting things the way they are - you could of course adjust this, but mine is setup so it works in Markdown.

The Macro is available here: lorem ipsum text generator.kmmacros (8.6 KB)

It doesn't have any trigger keys, so you can't accidentally trigger it which might be annoying.

Please share any improvements I could make!


#2

Hi Rosemary,

Great idea for a macro; I've had a lorem ipsum text snippet for a while, but never thought to make the number of paragraphs adjustable in a macro like this. I do see a way it can be improved though:

Lorem Ipsum Text Generator 1.1.kmmacros (3.8 KB)
image

This way, you don't have to account for the different Index variable values ahead of time, or otherwise hard-code different scenarios with a Switch/Case action; you can just enter the number of paragraphs and the macro will automatically create however many you enter.


#3

The reason for the micro management is so that I can have 5 different paragraphs - originally my macro was like yours but having the same text repeated 5 times is rather obvious :wink:


#4

Aha, now I understand. Having different text for each paragraph is something I never even thought of for filler text; this is really clever, and I happily stand corrected.

I do still have two suggestions for this macro, though: using variables instead of the clipboard (though of course this is only necessary if prefer to not have your clipboard history cluttered), and including a notification action at the end so you know that the macro executed successfully and that the text is ready to paste:

Lorem Ipsum Text Generator 1.1 - Take 2.kmmacros (9.4 KB)


#5

Those are indeed excellent suggestions! :grin:


#6

Color me simple, but this is just inserting a user-specified number of paragraphs of Lorem Ipsum into a document?


#7

Adding them to the clipboard to be precise, but yes! In my day job I'm a web developer and somewhat regularly need placeholder text because I'm building something that will contain some text at some point - but doesn't yet :slight_smile:


#8

May I offer my approach?


#9

Naturally! I always love to see different approaches, it's a great way to learn :slight_smile:


#10

Bear in mind, despite some of our customers using KM, I have used it for less than an hour :relaxed: I do a ton of AppleScript and shell scripting, hence my succinct approach…

Lorem Generator.kmmacros (16.8 KB)

07%20PM

The shell script results can also be put on the clipboard (or whatever), as the need dictates. I used it to directly paste into a Markdown document in DEVONthink Pro Office (though it would obviously work in plain text, rtf, HTML, Formatted Notes, etc. too)


#11

That's awesome! I don't spend enough time on the command line so wouldn't have thought of that approach at all :nerd_face:


#12

It could be easily done in pure AppleScript as well, but the shell is sexay (and powerful)!! :wink:

NOTE: to any curious/interested passers-by… The shell can be a very dangerous place. So don't treat my cavalier comment as a general beckoning to jump into Terminal and start messing about. Very bad things can happen, if you're not careful. And I have said for many years: In the shell, there is no forgiveness.


#13

I am happy to have an expert for DEVONthink marry in the forum @DEVONtech_Jim.
Every day I think about how I can improve my workflow with it. Thanks to KM, this is also possible for me as a layman, without extensive knowledge with scripts.


#14

@appleianer: Glad to be here. :blush:


#15

An alternative to using a shell script and sed to extract the required number of lines is to use a Search using Regular Expression action. Like this:

Keyboard Maestro Actions.kmactions (1.0 KB)


#16

Interesting alternate approach @peternlewis :blush:


#17

Hey Folks,

Yet another way is to use a remote API.

https://loripsum.net

Sample use of the API:

https://loripsum.net/api/10/short/headers

Download ⇢ Lorem Ipsem Online v1.00.kmmacros (10 KB)

-Chris


#18

Whenever I run either version (Rosemary's or gglick's), there is no difference between the output for 4 or 5 paragraphs; if I select the default of "5", the fifth paragraph is not included (the one that begins with "Pellentesque in maximus turpis."). Not a big issue, of course, but I can't see where the macro goes wrong, and that's a bit crazy-making!

(I'm a bit late to the party, but I've just seen this in the periodic KM Discourse summary.)