I have this snippet:
import HypertextLiteral
func layout(root: String, body: HTML) -> HTML {
#"""
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
\#([16, 32, 96].map { side -> HTML in
let size = "\(side)x\(side)"
return #"""
<link
rel="icon"
type="image/png"
sizes="\#(size)"
href="\#(root)/static/imgs/favicon-\#(size).png" />
"""#
}
)
</head>
</html>
"""#
}
With this config:
--indent 2
--indentcase false
--trimwhitespace always
--ranges nospace
--empty tuple
--operatorfunc nospace
--ifdef noindent
--stripunusedargs closure-only
--disable andOperator
--swiftversion 5.2
After formatting, the indentation within the interpolated bit is increased, but after another formatting run it is increased even further, here's how it looks after the first run:
#"""
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
\#([16, 32, 96].map { side -> HTML in
let size = "\(side)x\(side)"
return #"""
<link
rel="icon"
type="image/png"
sizes="\#(size)"
href="\#(root)/static/imgs/favicon-\#(size).png" />
"""#
}
)
</head>
</html>
"""#
and a second one:
#"""
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
\#([16, 32, 96].map { side -> HTML in
let size = "\(side)x\(side)"
return #"""
<link
rel="icon"
type="image/png"
sizes="\#(size)"
href="\#(root)/static/imgs/favicon-\#(size).png" />
"""#
}
)
</head>
</html>
"""#
Thanks, I'll investigate.
I've been able to narrow it down to the multiline interpolation bits (not counting for the inner multi-line string), when the interpolation is on a single line it's fine:
#"""
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
\#([16, 32, 96].map { side -> HTML in let size = "\(side)x\(side)"; return #"""
<link
rel="icon"
type="image/png"
sizes="\#(size)"
href="\#(root)/static/imgs/favicon-\#(size).png" />
"""# })
</head>
</html>
"""#
Fixed in 0.44.8
Fantastic, thank you so much @nicklockwood!