-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Problem
The latest version of YAML (1.2.2) has two major types of block scalars (also known as multiline strings) for keeping newlines and folding them:
- |
Literal
This line break is a newline character
- >
Folding
This line break is a space characterIt lacks a mode to transform the line breaks to nothing.
Current state
If we want to add line breaks between strings in YANL files for beauty and leave no characters there, the only way is using flow scalars:
- "\
space-\
less"which requires additional backslashes at the end of each line and the closing double quote.
How can this be useful?
For text, some languages don't use spaces to separate words, so the "anywhere" stated in the spec doesn't exist, making the purpose of multiline strings ineffective.
Folding allows long lines to be broken anywhere a single space character separates two non-space characters.
Possible solutions
To keep compatibility, I propose using an extra indicator after > for space-less mode, such as <. As normal folding block scalars, the existing indicators (indentation and chomping) still can be added, and each empty line is a newline character.
Example:
- ><
いづれの御時にか、女御、更衣あまたさぶらひたまひけるなかに、いとやむごとなき際
にはあらぬが、すぐれて時めきたまふありけり。
はじめより我はと思ひ上がりたまへる御方がた、めざましきものにおとしめ嫉みたま
ふ。同じほど、それより下臈の更衣たちは、ましてやすからず。朝夕の宮仕へにつけて
も、人の心をのみ動かし、恨みを負ふ積もりにやありけむ、いと篤しくなりゆき、もの
心細げに里がちなるを、いよいよあかずあはれなるものに思ほして、人のそしりをもえ
憚らせたまはず、世のためしにもなりぬべき御もてなしなり。
- ><-
孟子見梁惠王。王曰:「叟!不遠千里而來,亦將有以利吾國乎?」
孟子對曰:「王!何必曰利?亦有仁義而已矣。王曰:『何以利吾國?』大夫曰:『何以
利吾家?』士庶人曰:『何以利吾身?』上下交征利而國危矣。萬乘之國,弒其君者,必
千乘之家;千乘之國,弒其君者,必百乘之家。萬取千焉,千取百焉,不為不多矣。苟為
後義而先利,不奪不饜。未有仁而遺其親者也,未有義而後其君者也。王亦曰仁義而已
矣,何必曰利?」