Skip to content

feat(csv-stringify): preserve structure with relaxed quotes - #559

Merged
wdavidw merged 6 commits into
adaltas:masterfrom
asssslay:feat/stringify-relax-quotes
Nov 9, 2026
Merged

wdavidw merged 6 commits into
adaltas:masterfrom
asssslay:feat/stringify-relax-quotes

Conversation

@asssslay

@asssslay asssslay commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Disabling quoting can turn one field into several fields or records. This follows the requested alternative in #558: restore the previous disabled-quote behavior and make relaxed quotes an explicit relax_quotes option, defaulting to false.

With relax_quotes: true, interior quotes stay unchanged in unquoted fields. Fields containing delimiters, record delimiters, or leading quotes still receive enclosing quotes and normal escaping. Leading quotes after whitespace are also enclosed so a parser using trim does not mistake them for the start of a quoted field. Explicit quoting selectors continue to take precedence.

const options = { relax_quotes: true };
const text = 'say "hi",plain\n"a,b","a\nb"\n';
const records = parse(text, options);
const output = stringify(records, options);

assert.deepEqual(parse(output, options), records);
assert.equal(output, text);

The normal RFC 4180 quoting behavior remains the default. Relaxed output requires the matching parser option. The option is available in TypeScript and field-level cast settings, with a sample showing which fields remain enclosed. Generated distributions are left to the release build process.

@wdavidw
wdavidw force-pushed the feat/stringify-relax-quotes branch from 0c63634 to e678be7 Compare November 5, 2026 12:56
@wdavidw
wdavidw merged commit c72cc6c into adaltas:master Nov 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants