For one of my art projects I make YAML files that describe the front side, back side, and web side of a "three sided card". I generate these out of several templates, currently using ordinary string templating.
I'd love to be able to load a YAML file and add something programatically to the list and have the list stay in the same format that it was in, so if it was a
[1,2,3]
list I get [1,2,3,4]
if it was a - 1
- 2
- 3
list I want - 1
- 2
- 3
- 4
sadly I'm the only one who thinks this way.E.g. I tried exactly the same thing, and it was quiet difficult with Rust. Because the way to parse it usually is with serde and it just removes the AST of course.
In the end I gave up, and just used JSON for my use case.
import assert from 'assert'
import { parseDocument } from 'yaml'
const flowDoc = parseDocument(`[1,2,3]`)
flowDoc.add(4)
assert(flowDoc.toString(), '[ 1, 2, 3, 4 ]\n')
const blockDoc = parseDocument(`\
- 1
- 2
- 3`)
blockDoc.add(4)
assert(
blockDoc.toString(),
`\
- 1
- 2
- 3
- 4
`
)"<em>This</em> is a markup language" since there is text which is marked up.
YAML/JSON is a way to serialise fairly common data structures (arrays/lists, hashes/dictionaries, numbers, strings, bools, etc.)
Incidentally, if you can seamlessly replace XML with something like JSON, then you probably aren't using the 'markup' bit of XML.
YAML: Probably not so great after all (arp242.net)
https://news.ycombinator.com/item?id=20731160
https://www.arp242.net/yaml-config.html
To which I posted:
https://news.ycombinator.com/item?id=20735231
I was suspicious of YAML from day one, when they announced "Yet Another Markup Language (YAML) 1.0", because it obviously WASN'T a markup language. Who did they think they were fooling?
https://yaml.org/spec/history/2001-08-01.html
XML and HTML are markup languages. JSON and YAML are not markup languages. So when they finally realized their mistake, they had to retroactively do an about-face and rename it "YAML Ain’t Markup Language". That didn't inspire my confidence or look to me like they did their research and learned the lessons (and definitions) of other previous markup and non-markup languages, to avoid repeating old mistakes.
If YAML is defined by what it Ain't, instead of what it Is, then why is it so specifically obsessed with not being a Markup Language, when there are so many other more terrible kinds of languages it could focus on not being, like YATL Ain't Templating Language or YAPL Ain't Programming Language?
https://en.wikipedia.org/wiki/YAML#History_and_name
>YAML (/ˈjæməl/, rhymes with camel) was first proposed by Clark Evans in 2001, who designed it together with Ingy döt Net and Oren Ben-Kiki. Originally YAML was said to mean Yet Another Markup Language, referencing its purpose as a markup language with the yet another construct, but it was then repurposed as YAML Ain't Markup Language, a recursive acronym, to distinguish its purpose as data-oriented, rather than document markup.
https://en.wikipedia.org/wiki/Markup_language
>In computer text processing, a markup language is a system for annotating a document in a way that is syntactically distinguishable from the text. The idea and terminology evolved from the "marking up" of paper manuscripts (i.e., the revision instructions by editors), which is traditionally written with a red or blue pencil on authors' manuscripts. In digital media, this "blue pencil instruction text" was replaced by tags, which indicate what the parts of the document are, rather than details of how they might be shown on some display. This lets authors avoid formatting every instance of the same kind of thing redundantly (and possibly inconsistently). It also avoids the specification of fonts and dimensions which may not apply to many users (such as those with varying-size displays, impaired vision and screen-reading software).