I often receive a bulleted list of agenda items for meetings that I copy and paste into Drafts. I would like to figure out an action that would take this list and add blank indented sub-bullets to it.
I thought’s @agiletortoise’s Markdown List action would be a good place to start, but it is a much more complicated script than I am comfortable editing.
Okay, I’m sure someone else will suggest a far more sophisticated solution, but if you’re willing to experiment off the back of a suggestion, try this script step in an action:
Super simple, nothing fancy. This assumes you don’t have anything else in the draft, as pictured. If you sometimes start with a title, it wouldn’t be too difficult to adjust to ignore the n line(s). Also could be adjusted to work solely on selected text. Or could even be set to run on the clipboard instead of the draft, so instead of copying, pasting, and then running the action, you could just copy, then run the action and produce a new draft with the copied text, bulleted and indented… Possibilities!
At the end of the day, as long as you can use and maintain the code, then that’s all that really matters, but I would suggest the following in terms of potential modifications.
Try and get used to using let rather than var, though you could even use const, or forego the use of a separate variable entirely by merging the first and second line (though some may find merging harder to read). Using a definition with a restricted scope can save you errors when you deal with more complex code.
Be consistent with your structure - it makes it easier to read and follow your own code.
Be consistent with your semicolons. If you are going to end lines with semi colons, try to always end with them.
Be consistent with your use of spaces. You have a rogue space on line two after the opening parenthesis.
You are working with the editor and not changing the draft object, so the last line to update the draft I believe is redundant.
If it is something you may not follow a year from now, consider adding a comment line, even if it just links to this thread.
I needed exactly what the post title is: “Create Markdown Sub-Bullets.”
The script above didn’t work for what I needed - I tried it. It messed up my list with too many spaces between lines.
I wrote my my own script/action with the help of ChatGPT. It worked like a charm. But the action wasn’t really needed either. This is what I was trying to accomplish:
Here is the action I use to achieve the my goal in the original image.
I have a plain text list of items (not formatted in markdown) in a draft, I select the list and use this action to turn the selection into a markdown formatted list with blank sub-bullets.