Adjustment to plain scalar flow style for "1.3".
Trans <[email protected]> Tue, 15 Nov 2016 23:32:56 -0500
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CAEu+kw0H19kMSgd4qyrr4TqD_pgQ0ovSt3bbFS=E=TneWi9R=A@mail.gmail.com> |
Not sure where to suggest this in github issues b/c it's not so major (IMO)
to be a "2.0" idea, so I decided to post it to the mailing list.
I was thinking that the plain scalar flow spec isn't optimal for most use
cases. Namely that blank line
s
get "folded" such that it take
s
two blank line
s
to achieve one in the result.
e.g. this example has no blank line in the result:
y = <<-YAML
---
This is a test
of this idea.
How about it?
YAML
=> "---\nThis is a test\nof this idea.\n\nHow about it?\n"
YAML.load(y)
=> "This is a test of this idea.\nHow about it?"
W
e need two blank lines to get one:
y = <<-YAML
---
This is a test
of this idea.
How about it?
YAML
=> "---\nThis is a test\nof this idea.\n\n\nHow about it?\n"
YAML.load(y)
=> "This is a test of this idea.\n\nHow about it?"
In practice this blank line behavior isn't very useful. In fact I can't
think of a single case were one would actually want that. If the text is
say, HTML or XML, it doesn't matter at all (excluding
perhaps
CDATA), but for something like Markdown, then it does matter and the blank
line is significant, so having to put two blank lines is not nice and
thwarts readability. The same I think will be true for just about all plain
text.
So how about we adjust the spec to allow blank lines to remain blank lines,
and only flow the text when the next line isn't blank. So instead it would
do:
y = <<-YAML
---
This is a test
of this idea.
How about it?
YAML
=> "---\nThis is a test\nof this idea.\n\nHow about it?\n"
YAML.load(y)
=> "This is a test of this idea.\n\nHow about it?"
While I still tend to think plain style would be better off acting like
literal style -- because the application can always strip out newlines
itself, but it can't get back wh
a
t has already been taken away
-- nonetheless, this simple adjustment to plain flow style would
alleviate most of the use case issues I've ever come across in practice.
trans
------------------------------------------------------------------------------
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core