Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/tour/types/stringlit: prose explaining multi-line string whitespace is technically incorrect #174

Open
jpluscplusm opened this issue Jul 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jpluscplusm
Copy link
Collaborator

jpluscplusm commented Jul 30, 2024

What page were you looking at?

https://cuelang.org/docs/tour/types/stringlit/

What version of the site were you looking at?

cue-lang/cuelang.org@fccf480

What did you do?

I tried to rely on this phrase when writing a multi-line string that contains blank lines:

Any whitespace before the closing quotes must also prefix the lines between the quotes, because it is removed from all lines.

What did you expect?

I expected that blank lines inside a multi-line string would require the string's standard whitespace prefix.

What did you see instead?

The prefix is not required when the intent is to encode a blank line:

exec cue export foo.cue
cmp stdout out
-- foo.cue --
x: """
	The next line is totally blank.

	The next line is blank, but the CUE has a tab prefix
	
	This is the last line.
	"""
-- out --
{
    "x": "The next line is totally blank.\n\nThe next line is blank, but the CUE has a tab prefix\n\nThis is the last line."
}

(This example doesn't make it clear via the web view, but the copy button does generate the correct underlying txtar that demonstrates the corner case)

@jpluscplusm
Copy link
Collaborator Author

The spec's language makes this clear:

The whitespace before a closing triple quote must appear before any non-empty line after the opening quote and will be removed from each of these lines in the string literal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant