Repository navigation
feat: Support YAML literal blocks for multiline strings - #851
Conversation
|
thanks for the contribution what's the standard for frontmatter — are these allowed? I agree this makes it more readable. OTOH it adds another option + introduces backward-compat issues, so need to weigh those... |
|
Thanks for the quick reply :)
Yes! Literal blocks are standard YAML so any compliant parser handles them, and frontmatter is YAML between
Added as opt-in so users control the switch. Older |
|
yes, another option would be "min-version", which we've thought about a bit before... I think the versioning is basically the only reason to have the config here; so in that case we could just adopt the "min-version" config. Or push this to #456 let me leave this open for a bit to see if others have thoughts (including @mitsuhiko ) thank you again |
|
Hi @max-sixty! I was wondering if you or @mitsuhiko had time to think about this one. Happy to close it out if the tradeoff isn't worth it for you. In any case thanks for the great lib. |
|
I think this is an improvement, but I'm very keen to avoid backward compat breaks Would you be up for:
we could add a hope that's reasonable! my main focus is that anyone running on default doesn't start getting compatibility errors because one person on the team upgraded before others... |
|
Thanks for your quick reply! I want to make sure I'm understanding you correctly. There are two things "compatibility errors" can mean: (1) old reader chokes on For (1), this is not an issue. From what I see, the scanner has handled For (2), default behavior is unchanged. In this PR the writer is already behind Options, as far as I understand:
For context on the motivation, I maintain the |
|
sorry! it had been a while and I should have reminded myself of the PR before launching into a proposal, which your code already did! merging + thank you very much for the code & patience! |
Minor release. Highlights since 1.47.2: - `strip_ansi_escape_codes` setting (#899, @pierluigilenoci) - Opt-in YAML literal blocks for multiline metadata strings via `INSTA_YAML_BLOCK_STYLE=1` (#851, @ivov) - An explicit `--accept` now overrides `CI=true` (#924) - `cargo insta test --profile` now translates to nextest's `--cargo-profile`; new `--nextest-profile` flag (#910) - Windows `--snapshot` path fix and partial-path filter matching (#904) - Accepting a binary snapshot tolerates a missing data file (#914) > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Thanks for the project!
This PR adds opt-in support for YAML literal blocks for multiline strings in snapshot metadata fields like
descriptionandexpression. Trailing newlines are preserved via chomping indicators (|-,|,|+).Set
INSTA_YAML_BLOCK_STYLE=1to enable.Before:
After:
I noticed the YAML lib is vendored and assumed extending it was acceptable - please let me know if you'd prefer a different approach.
Closes #782