Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a mechanism or pattern for Block Style Literal Strings #34

Open
Bengreen opened this issue Dec 15, 2022 · 3 comments
Open

Is there a mechanism or pattern for Block Style Literal Strings #34

Bengreen opened this issue Dec 15, 2022 · 3 comments
Assignees
Labels
custom-yaml-engine Issue to consider for a custom YAML engine enhancement New feature or request

Comments

@Bengreen
Copy link

I have a string content that is muliline and currently I can use pydantic-yaml with ruamel to dump it as yaml.
It uses the quoted string format.

Is there an option to use the block style ?

Or can suggest some options to consider.

https://yaml-multiline.info

@NowanIlfideme NowanIlfideme self-assigned this Dec 15, 2022
@NowanIlfideme NowanIlfideme added the enhancement New feature or request label Dec 15, 2022
@NowanIlfideme
Copy link
Owner

Hi, improving the flexibility of dumping YAML is something that's been on my wanted list for a while. It might wait until Pydantic 2.0 releases and I'll need to totally rewrite this... I'll probably base it around ruamel's or even (shudders) do the YAML part myself.

@NowanIlfideme NowanIlfideme added the custom-yaml-engine Issue to consider for a custom YAML engine label Dec 15, 2022
@NowanIlfideme
Copy link
Owner

Hi @Bengreen, in terms of user experience - would you prefer to do this configuration within the model class itself (using Pydantic-like config class) or within the "dumping engine" as a global configuration? How did you use it in the case above?

@NowanIlfideme
Copy link
Owner

Currently, limited support for this is now available within to_yaml_str and to_yaml_file using dumping keywords (since 1.1.0), or with a custom YAML dumper instance. For example, you could try configuring text longer than some length to use a block style. You'll have to go through the internals of ruamel.yaml though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom-yaml-engine Issue to consider for a custom YAML engine enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants