1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

toml: eat first nl if present in multiline strings (#12496)

This commit is contained in:
Larpon
2021-11-17 22:48:29 +01:00
committed by GitHub
parent 81455acd29
commit 3b612899bf
3 changed files with 14 additions and 6 deletions

View File

@ -1127,6 +1127,13 @@ pub fn (mut p Parser) quoted() ast.Quoted {
mut lit := p.tok.lit[1..p.tok.lit.len - 1]
if is_multiline {
lit = p.tok.lit[3..p.tok.lit.len - 3]
// From https://toml.io/en/v1.0.0#string
// "Multi-line literal strings [...] A newline immediately following the opening
// delimiter will be trimmed. All other content between the delimiters
// is interpreted as-is without modification."
if lit.len > 0 && lit[0] == `\n` {
lit = lit[1..]
}
}
return ast.Quoted{
text: lit