flyx / NimYAML

YAML implementation for Nim
https://nimyaml.org
Other
186 stars 36 forks source link

Feature: Let user choose/disable maximum line length for presentation #119

Closed iacore closed 2 years ago

iacore commented 2 years ago

When exporting URL, it likes to butcher the output.

import yaml/serialization, std/streams

type A = object
  foo: string

let a = A(foo:"/sites/default/files/styles/square/public/media_2022/07/202207africa_angola_dossantos.jpg?h=1305ebec&itok=GSD3Irma")

var s = newFileStream("/tmp/test7.yaml", fmWrite)
dump(@[a], s)
s.close()

output:

> cat /tmp/test7.yaml
%YAML 1.2
%TAG !n! tag:nimyaml.org,2016:
--- !n!system:seq(tag:nimyaml.org;2016:custom:A) 
- 
  foo: "/sites/default/files/styles/square/public/media_2022/07/202207africa_angol\
    a_dossantos.jpg?h=1305ebec&itok=GSD3Irma"⏎ 

Is there any way to make it not do that? It also does that with psMinimal.

flyx commented 2 years ago

Can you be more precise about what bothers you? Perhaps show what output you expect?

flyx commented 2 years ago

If this is simply about the newline, I'm afraid there currently isn't an option to disable it. When I wrote this code apparently I was appalled by lines having more than 80 characters so I hardcoded that limit. This is not a good state of affairs.

Transforming this into a feature request for the user to be able to set or disable line wrapping.

iacore commented 2 years ago

Can you be more precise about what bothers you? Perhaps show what output you expect?

It makes URL hard to read (they shouldn't be broken in the middle).

flyx commented 2 years ago

This feature has been implemented and can now be used like this:

dump(@[a], s, options = defineOptions(maxLineLength = none(int)))