function escape(delim) {
  let result = '';
  for (const char of delim) {
    result += `\\${char}`;
  }
  return result;
}
escape

Simple replacement function for escaping markdown entities. Prepends every
character in the received string with a backslash.