Howdy, Stranger!

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

[Bug] Links don't work if you put an array in them.

$exit[0].text is a valid variable name.

<<$exit[o].text>> will print out it's value.

[[<<#exit[0].text>>|somewhere]] however does not work.  The editor and runtime both seem to the the closing square bracket on the array reference as the end delimiter for the link.

Should I raise an issue for it?

Comments

  • Try:

    [[$exit[0].text|somewhere]]
  • The editor rejects it (fails to parse it and highlight it as a link) as soon as I put the close square bracket on the array reference in.

    Printing is, I think, necessary to get the variables contents shown on the screen - it seems to work for simple variables.
  • There are a couple of cases where a link is valid even though the syntax highlighter says otherwise, especially if using SugarCube.

    Did you test what "The Pixie" suggested by generating a HTML file and testing it, or did just type it into the editor and notice the highlighter was not happy?
  • Tried it in Test and [[$exits[0]|Self]] as the link produced $exits[0]|Self]] as normal text.

    [[<<$exit[0]>>|Self]] produced  North|Self]] - as normal text.

    [[<<print $exits[0]>>|Self]] also produced North|Self]] - as normal text.

    Last test code was:
    <<set $exits to [ 'North', 'South']>>
    [[<<print $exits[0]>>|Self]]


  • I believe that issues with $variables that include property accessors (or at least those containing the bracket notation) in the vanilla headers are probably a known quantity (I could be wrong though).  Regardless, it can't hurt to raise an issue about it, so I would probably suggest doing so.




    Tangentially, since SugarCube was brought up, in most places where SugarCube supports $variables, it supports variables of arbitrary complexity.  Meaning:

    /% This will work fine as-is. %/
    [[$exit[0].text|somewhere]]

    /% So will this monstrosity. %/
    [[$l.m.n.o.p['q']["r"]['s'].t.u.v.w.x[$y].z|somewhere]]
    The only caveat is within the wikitext link and image markup.  If the $variable ends in the square-bracket notation and would adjoin the closing square-brackets of the link/image markup, then you'll need to add space between the $variable and the closing square-brackets of the markup (since it would otherwise be ambiguous to the parser).  For example:

    /% This won't work, since $link["location"] directly adjoins the closing square-brackets of the markup. %/
    [[$link["text"]|$link["location"]]]

    /% This is okay. %/
    [[$link["text"]|$link["location"] ]]

    /% This is also okay (though now I'm just being silly). %/
    [[
    $link["text"]
    |
    $link["location"]
    ]]
Sign In or Register to comment.