encloseQuote method

String encloseQuote()

Implementation

String encloseQuote() {
  // Escape '' first
  var replaced = replaceAll("''", "__‹ESC_QUOTE›__");

  // Escape '{...}' if enclosed in single quotes
  replaced = replaced.replaceAllMapped(
    RegExp(r"'(\{[^}]+\})'"),
    (match) => match
        .group(1)!
        .replaceAll('{', '__‹ESC_OPEN›__')
        .replaceAll('}', '__‹ESC_CLOSE›__'),
  );

  return '__‹ESC_OPEN›__${this}__‹ESC_CLOSE›__';
}