sugarcube-2
sugarcube-2 copied to clipboard
2.36.1 : Link expressions are not evaluated when they contain a " enclosed in single quotes
Describe the bug.
The link markup (https://www.motoslave.net/sugarcube/2/docs/#markup-link) says that the Text
part of a link can contain "any valid TwineScript expression", however a Text part containing a single double-quote mark causes the entire link not to be evaluated, even if that double-quote is escaped inside a single-quoted string.
To Reproduce: Create the following:
[['link 5"'|passage]]
<<print 'link 5"'>>
Expected behaviour.
The link should render as link 5"
, the same as the <<print>>
Instead the link does not render at all, while the print does.
Screenshots.
A link formatted as [["link" + "5\""|passage]]
does work, however
Project details.
- SugarCube Version: 2.36.1
- Compiler & Version: Twine 2.4
Desktop details.
- OS & Version: MacOS 10.15.7
- Browser & Version Firefox 101.0.1 (64-bit)
It's less a bug—though it is that—and more an unfortunate, and undocumented, "feature".
Also, the actual issue is that: single quotes aren't recognized as a valid quoting syntax within the link & image markup.
Unfortunately, there's not much I can do about it at present. Anything I could do risks breaking existing projects and wouldn't help much regardless. The current markup syntax is an unfortunate confluence of legacy suck.
I'm leaving this open in case something amazing occurs to me, but I'm not holding out much hope that this will be fixed before v3.
I suppose the answer it to compose the link text as a variable first?
Yes. Using a temporary variable would work. For example:
<<set _ltxt to 'link 5"'>>[[_ltxt|passage]]
Using double quotes and escaping the inner double quote should also work:
[["link 5\""|passage]]
Using the appropriate character, the double prime, should also work:
[[link 5″|passage]]
[[link 5″|passage]]