sugarcube-2 icon indicating copy to clipboard operation
sugarcube-2 copied to clipboard

2.36.1 : Link expressions are not evaluated when they contain a " enclosed in single quotes

Open hituro opened this issue 2 years ago • 3 comments

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. Screenshot 2022-07-07 at 23 58 52

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)

hituro avatar Jul 07 '22 23:07 hituro

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.

tmedwards avatar Jul 13 '22 21:07 tmedwards

I suppose the answer it to compose the link text as a variable first?

hituro avatar Jul 13 '22 21:07 hituro

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&Prime;|passage]]

tmedwards avatar Jul 13 '22 22:07 tmedwards