Is there a way to embed a double quotation mark inside a string?
I was trying to display a string in color; but the string i wanted included a quotation (i.e. it had quotation marks around it, which I also wanted to appear in color).
I was trying to display a string in color; but the string i wanted included a quotation (i.e. it had quotation marks around it, which I also wanted to appear in color).
1 Answer
Yes, there is.
Explanation:
The trick here is to use the text() function in between hashtags.
For example, something like
hashtag text("quote marks") hashtag
will get you
#text("quote marks")#
As you can see, the quote marks are included in the string, and thus do not act like text delimiters like they normal do when placed in between hashtags. The same example without the text() function would be
hashtag "quote marks" hashtag
#"quote marks"#
To use color, embed the text() function in a color() function. This time
hashtag color(red)(text("quote marks")) hashtag
will get you
#color(red)(text("quote marks"))#