Comments (8)
Probably duplicate of #105, try nimble install yaml#head
and see if it goes away.
I should do a release with this fix…
from nimyaml.
I ran the command you suggested and neither installing or searching for this yielded any packages with nimble
from nimyaml.
Well I don‘t know your setup. On a proper nimble installation it should fetch the current master version of NimYAML, which incorporates the fix mentioned.
If your setup doesn‘t allow you to do this for some reason, you have to wait for the next release. I estimate this to happen in 2-3 weeks.
from nimyaml.
I just remembered they changed the syntax, it's nimble install yaml@#head
.
from nimyaml.
Ah, I see, I was a bit stumped by that as I thought I did have a proper installation of the library. I will try this when I get home from work and let you know if it fixes the issue. However, I had a question about the library-- I hacked up the presenter file on my machine to give me more so the behavior that I wanted, which is that it does not create new lines for values whatsoever. I then noticed that this was writing the values (sometimes) with double quotes, and (sometimes) not with double quotes, so I incorporated a function in my code to execute a perl command to remove every double quotation mark from the file that was written. Perhaps I've only made this unnecessarily messy and difficult for myself... Does this library have ways to control those formatting choices without hacking on the presenter file?
from nimyaml.
Does this library have ways to control those formatting choices without hacking on the presenter file?
There's PresentationOptions but it doesn't offer much. Generally, NimYAML's presenter has been written with the assumption that you serialize data for communication between software. Hence it cares only about the output being valid YAML, but not much about how the output formatted; as long as it's valid YAML, the software on the other end will be able to load it. The reason for that assumption is that if you cared about details of the presentation, you would probably choose another format like XML that gives far less leeway to formatting than YAML does, and hence will give you better control about how it looks when you serialize it.
NimYAML does allow for some more control over the output format via its YamlStream interface:
import yaml
proc dumpModified[T](value: T, target: Stream) =
var
origEvents = represent(value) # add other args as needed
buffer = newBufferYamlStream()
for e in origEvents:
case e.kind
of yamlScalar: e.scalarStyle = ssPlain
else: discard
buffer.put(e)
present(buffer, target) # possibly give options here
(I'm not using Nim anymore apart from maintaining this lib so beware of errors)
This code would set the style of all scalars to plain (i.e. without quotes). If you need to choose different styles for different data, write custom representObject
functions for your types and generate Events with the style set appropriately, as explained in the docs.
from nimyaml.
Ah, perhaps I should stop being so finicky about the format of something only I will see. However I will give this example a shot and see how it goes. You can probably close this issue if it is going to be fixed in the next release, and I'd like to say thank you for communicating with me about it, and for being very helpful when you were able.
from nimyaml.
I'd say it's a bit of a design problem of YAML to say "I'm a serialization language but you can use me in a lot of different styles". There will always be a discrepancy between how a user can style a YAML file and how a YAML implementation can, and that does cause friction because users want the implementation to write YAML like they do, and usually it doesn't. For example, very few YAML implementations, and certainly not NimYAML, can write comments.
Closing this as duplicate.
from nimyaml.
Related Issues (20)
- Anchor in ignored tag HOT 5
- Feature: Let user choose/disable maximum line length for presentation HOT 4
- BUG: loading zero to unsigned integer generates a YamlConstructionError
- BUG: loading to float32 generates an error HOT 3
- Can't get optional fields to work HOT 3
- ignore pragma doesn't work on nested maps HOT 1
- nimble install yaml fails on devel version of Nim (needs new release) HOT 1
- Crashes on incorrect YAML HOT 2
- Raise an unlisted exception HOT 13
- Parent fields cause failure when deserializing child object HOT 3
- Catchable exception warnings HOT 2
- Seemingly pointless proc HOT 6
- Implement Sane Defaults HOT 5
- Field name causes `Error: ambiguous identifier` for no relevant Reason HOT 2
- Dumping doesn't work at compile time
- Nim CI is broken HOT 1
- Dumping broken in way too many ways HOT 5
- Can not dump floats HOT 1
- Can't load a dumped OrderedTable if it has a long string key with brackets HOT 1
- Demo website has a 404 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimyaml.