From: Oren Ben-K. <or...@be...> - 2004-11-12 12:20:43
|
On Friday 12 November 2004 13:00, Damian Cugley wrote: > > ... if we go Brian's way - require top-level scalars to be > > indented - can we also change the start/end lines to be "%---" and > > "%===" (or some other pair of lines starting with "%")? > > Writers need to know to quote keys starting with '%' (I recently had > to do this in a table of units of measure, which included '%' as a > unit). Having to do the same with '---' used as a key is just the > same, right? No. The '%' is a (reserved) indicator, like '!', '|', '>', '&', '*' etc. As such, it can't appear as the first character in a plain scalar anywhere - not just in unindented ones. In contrast, we can't forbid '-' from being a leading character because of negative numbers ("foo: -123"). So, the '---' can't start a plain scalar only if its unindented: --- --- : Ok, indented ... --- --- : Error, not indented ... I'd like to avoid this special case if possible. > Consider the log-file use-case. The following fictional log is > readable without knowing anything about YAML: > > --- > date: 2004-11-12 > message: overflow in silo 12 > --- > date: 2004-11-13 > message: underflow in silo 11 > > Using '%---' (or even %{...%}) would be distracting at best. I admit that "%---" stands out more. But, this is a document boundary, you'd expect it to stand out: %--- date: 2004-11-12 message: overflow in silo 12 %--- date: 2004-11-13 message: underflow in silo 11 %=== Using %{ %} is more quiet: %{ date: 2004-11-12 message: overflow in silo 12 %{ date: 2004-11-13 message: underflow in silo 11 %} There are a zillion more possibilities we could use. Surely we can find one that looks good: %- date: 2004-11-12 message: overflow in silo 12 %- date: 2004-11-13 message: underflow in silo 11 %= %--- date: 2004-11-12 message: overflow in silo 12 %--- date: 2004-11-13 message: underflow in silo 11 %+++ %---% date: 2004-11-12 message: overflow in silo 12 %---% date: 2004-11-13 message: underflow in silo 11 %+++% %%%%% date: 2004-11-12 message: overflow in silo 12 %%%%% date: 2004-11-13 message: underflow in silo 11 % % % We could also co-opt other indicators, like ">" and "|": >>> date: 2004-11-12 message: overflow in silo 12 >>> date: 2004-11-13 message: underflow in silo 11 ||| Hmmm. I think I like this one. Much more quiet than using '%' and still doesn't conflict with anything. How about it? Have fun, Oren Ben-Kiki |