ID:155438
 
This is concerning the use of line breaks inside of .yml files, so that the machine can still process the information without including the line breaks inside of the values but still keeping the original .yml file easy to read by those who might want to change it.

So yeah, are there any libraries out there? I'm sure there is some library that does it, but I haven't found one yet.
If I think I know what you mean just make it like like line breaks in BYOND strings: "\n", so after processing a value in whatever way you needed to and just use a text replace to replace line breaks with '\\n' and then when reading values parse for those and add the line breaks back in. Doesn't have to be \\n, can be any symbol really.

"This is some text with a line break
In the middle of it that we don't want."

"This is some text with a line break\\nIn the middle of it that we don't want."

proc
textreplace(text as text, to_replace as text, replacement as text)
var/pos = findtext(text, to_replace)
var/replacement_length = length(replacement)
var/to_replace_length = length(to_replace)
while(pos)
text = copytext(text, 1, pos)+replacement+copytext(text, pos+to_replace_length)
pos = findtext(text, to_replace, pos+replacement_length)
return text
textreplaceEx(text as text, to_replace as text, replacement as text)
var/pos = findtextEx(text, to_replace)
var/replacement_length = length(replacement)
var/to_replace_length = length(to_replace)
while(pos)
text = copytext(text, 1, pos)+replacement+copytext(text, pos+to_replace_length)
pos = findtextEx(text, to_replace, pos+replacement_length)
return text
In response to ExPixel
I'm not sure if line breaks from text documents show up the same as line breaks in BYOND user-inputted text strings.
I'm fairly sure they don't, because I do know how to parse things in and out, but I'm not sure how to *detect* a line break from a text document.
In response to Oasiscircle
findtext(text, "\n") will return a non-zero if there is a line break and tell you where it is?
In response to ExPixel
Really? I didn't know that.
I'll try that out, then.