Function preprocessQuotes

  • Preprocess quotes in input content.

    Automatically detects and escapes unescaped quote characters based on format. Returns the input unchanged if no broken quotes are detected or if an error occurs.

    Parameters

    • content: string

      The raw input content to preprocess

    • format: Format

      The format of the input ('yaml', 'json', or 'csv')

    Returns string

    The preprocessed content with quotes properly escaped, or original input if unchanged/error

    Example

    // Fix broken YAML
    preprocessQuotes('desc: "say "hi""', 'yaml');
    // Returns: 'desc: "say \\"hi\\""'

    // Fix broken JSON
    preprocessQuotes('{"a": "say "hi""}', 'json');
    // Returns: '{"a": "say \\"hi\\""}'

    // Fix broken CSV
    preprocessQuotes('A,B\\n1,"say "hi""', 'csv');
    // Returns: 'A,B\\n1,"say ""hi"""'