DayOne -> Drafts -> Things: ChatGPT generated script

Might be of interest:

I had an obscure problem. I make journal entries in DayOne and enter todos as ‘- todo’ (i.e. hyphen then name of todo). DayOne formats these as blue dots. ie if I think of a todo, I add the hyphen/bullet into the text as I write and carry on with my entry.

I then cut and paste the journal entry to Drafts and delete all the extraneous text, and edit so I can run the Things parser. The paste operation means the custom DayOne markdown blue dot bullet is replaced with a ‘•’. The Things parser script in Drafts expects a ‘-‘. DayOne tech support says modifying their custom markdown is not possible.

I realize in Drafts, I could find/replace all ‘•’ with ‘-‘.

Out of curiosity, I prompted ChatGPTL

“Create Drafts script to convert DayOne custom markdown bullet to standard markdown bullet.”

It produced the following result (with an explanation):

function convertBullets(line) {
  return line.replace(/.\s/, '- ');

let lines = draft.content.split('\n');
let output = [];
for (let line of lines) {

draft.content = output.join('\n');

It took me a couple of tries to fix the script by replacing the period ‘.’ with ‘•’: ie replace

return line.replace(/.\s/, '- ‘);
return line.replace(/•\s/, '- ');

I’d never tried scripting in Drafts before. ChatGPT gave me a very useful start!


Using GPT Toy | Drafts Directory, one can complete the script generation within Drafts!

Interestingly, the ChatGPT API call generated a regular expression (below), whereas the ChatGPT UI returned a function.

let content = draft.content;
let regex = new RegExp("• ", "g");
let newContent = content.replace(regex, "- ");
draft.content = newContent;