#YAML clarifications

8 messages · Page 1 of 1 (latest)

jolly gate
#

https://typst.app/docs/reference/data-loading/yaml/ -- which version of YAML and which library? I love the general format of YAML but hate the little bizarroquirks like on meaning true, or 5:00 being parsed as 300. Here's the nauseating behavior of PyYaml 6.0:

>>> import yaml
>>> yaml.safe_load('''
... a: [yes, no, maybe]
... b: on
... c: 5:00
... d: 7e3 
... e: 7.0e3
... f: 7e-3
... g: 7.0e-3
... ''')
{'a': [True, False, 'maybe'], 'b': True, 'c': 300, 'd': '7e3', 'e': '7.0e3', 'f': '7e-3', 'g': 0.007}
Typst

Documentation for the yaml function.

hallow wadi
#

YAML 1.2 parsed by serde_yaml 0.8.

#

We can add that to the docs

jolly gate
#

Any consideration of using yaml.read(filename) instead of yaml(filename) ?

#

(not sure what other methods would be appropriate besides read; there's the obvious write but not sure you want to allow file writing, and then there's the question of whether yaml parsing of strings or serialization of objects should be supported e.g. yaml.parse(some_string_containing_yaml) which would return an object, or yaml.represent(some_object) which would return a string

hallow wadi
#

I'm not sure how useful represent would be. I can imagine letting yaml take a string that should be retrieved from read though. However, if we do that, better soon rather than later because of breakage. Alternatively, things could stay as-is and the data loading functions could each get an optional parameter that takes a source string instead of path.

jolly gate
#

I'm not sure how useful represent would be.
I'll add another comment about some use cases.