- changed status to invalid
[Literal style dump] Line Feed + Space (LF + space) symbol prevents Literal style
Issue #439
duplicate
Dear Snakeyaml Team,
Please find the below Java test case:
package apryamostanov.snakeyamltests;
import org.junit.Test;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
public class LiteralStyleLineBreakSpaceTest {
@Test
public void test() {
DumperOptions options = new DumperOptions();
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.LITERAL);
Yaml yaml = new Yaml(options);
String correct = "this is some text with \"quotes\" and\nline breaks";
String correctYaml = yaml.dump(correct);
System.out.println(correctYaml);
assert correctYaml.contains("|");
String inCorrect = "this is some text with \"quotes\" and \n line breaks";
String inCorrectYaml = yaml.dump(inCorrect);
System.out.println(inCorrectYaml);
assert inCorrectYaml.contains("|");
}
}
Actual result: second assertion fails Expected result: both assertions should pass
Note: the space
character prevents usage of LITERAL scalar style when it is accompanying the Line Feed
character.
However it should not prevent, there is no such rules in YAML spec.
Comments (3)
-
-
reporter - changed status to open
The question is why the trailing spaces are removed in Literal style?
Can you point to a reference in Yaml specification?
-
- changed status to duplicate
Duplicate of
#440. - Log in to comment
The issue hear is that the trailing spaces in every line are removed in the literal style.
That is why the style is changed.