Howdy, Stranger!

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

[Harlowe] Closing parenthesis without opening one wrongly interpreted as end of macro

edited December 2015 in Help! with 2.0
Consider this:
(set: $a to (datamap:
1, "test",
2, ")"
))

I want to use the closing parenthesis symbol as a piece of text, that's why it's between double quotes.

The problem is that Harlowe wrongly understands that parenthesis as pairing with "(datamap:" and closing the macro. The closing parenthesis always gets paired to the nearest opening parenthesis, even if quotes should prevent that.

Putting the parenthesis between inverted commas, "`)`", didn't help me either.

Just in advance of replies: no, I can't use another character, only ")", and yes, it has to be unpaired, no previous "(".

Is there any way I can do this? Is this a legitimate bug? Thanks!

Comments

  • Use a backslash to escape the bracket
    (set: $a to (datamap:
    1, "test",
    2, "\)"
    ))
    
  • Thanks, that did it!

    Is this documented? The manual tells about tildes to escape markup, and the backslash only for line breaks.
  • edited December 2015
    @Menti

    The backslash character is used to escape special characters within a Javascript String value, although a close parenthesis is not normally considered a special character. The backslash is also used to escape special characters in a regular expression and the close parenthesis is a special character in them.

    The fact that you needed to escape the close parenthesis leads me to believe that you have found a bug in the regular expression used for either the (datamap:) or (set:) macro.
    I suggest you create a new issue on the Harlowe project website so that it can be fixed.
  • Thanks for noting this - I'll have a fix in the next version, no report needed.
  • I must say that I used (datamap: ) as an example, but I observed the same problem using other values within a (set:) macro.

    I just checked that this most simple example doesn't work:
    (set: $a to ")")
    

    Thanks everyone.
Sign In or Register to comment.