Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Displaying double quotes, apostrophes, and single quotes(SugarCube)

I'm brand new here, just joined the forums to ask this question. I tried searching for a bit but didn't see anyone with this particular issue.

So, I'm using SugarCube in Twine 2.0, and I want links to passages to be verbal responses, hence in "quotes", and I want them to be stored in variables, so that I don't have to rewrite them when they appear multiple times. If I try to use <q></q> it simply prints <q></q> in the story, rather than converting them to quotation marks. I can get it to work by wrapping the string in single quotes and then using double quotes within that string. E.g. if I write: '"hello, there"', then it will display: "hello, there".

The problem I'm having is that, if I use that method, I can't use apostrophes for contractions because they are interpreted as single quotes ending the string.

Surely there is a way to have access to all punctuation while still taking advantage of Twine's features?

Thanks for the help.


  • The strings used in SugarCube are standard Javascript ones, so you can use a backslash \ character to escape out special characters like double quotes. The backslash is placed before the special character you wish to escape.

    note: It was not clear exactly which parts of a markup link you are trying to store in a variable, so I am going to assume it is the Link Text part.
    <<set $linkText to "\"This text is quoted.\"">>
    [[$linkText|Next Passage]]
  • Greyelf,

    Thanks very much. Sorry I didn't include an example to make things clearer. You guessed correctly.

  • Because of the way SugarCube treats the components of wiki links (i.e. links made using the double square bracket syntax), you cannot simply use markup within them. As noted by greyelf, escaping the quotes in some fashion is the way to go.

    An alternative to manually escaping the content of wiki links is to use the <a> tag with the data-passage attribute, which does allow for markup. For example:
    <a data-passage="Foo">"This text is 'quoted'."</a>
    <a data-passage="Foo"><q>This text is <q>quoted</q>.</q></a>
Sign In or Register to comment.