Stealthy Links in Sugarcube 2

Twine Version:2.3.5
Story Format: 2.30

Hello, I am trying to modify links that appear in a paragraph so that they appear just like the surrounding text. I would like this to work with both passage links and links that just modify variables. I have gotten this to work for passages but not for any other sort of link.

I have been using this in the stylesheet

.secret.link-internal,
.secret.link-internal:hover {
color: inherit;
font-weight: inherit;
text-decoration: none;
}

And using it in the passage like this

Off to one side is a <a class="secret" data-passage="HiddenPassage">painting</a>.

This works fine when I want to move to a new passage but does not work when I try to use a to modify a variable without leaving the passage.

Am I missing something obvious in the stylesheet or use?

Thanks in advance

You cannot use regular links—either link markup or data-passage bearing anchors—to execute code in-place. While they can execute code, via their setters, they’re meant primarily for passage navigation.

If you want a link that can execute code without navigation, then you’ll want the <<link>> macro. For example:

Off to one side is a <<link "painting">><<set $badTouch to true>><</link>>.

To make that stealthy, simply modify your style like so:

.secret a.link-internal,
.secret a.link-internal:hover {
	color: inherit;
	font-weight: inherit;
	text-decoration: none;
}

Then wrap the <<link>> like one of the following:

/* Via custom style markup. */
@@.secret;<<link "painting">>…<</link>>@@

/* Via a <span>. */
<span class="secret"><<link "painting">>…<</link>></span>

Additionally. That same modified style rule will work for both types of regular links as well. For example:

/* Link markup. */
@@.secret;[[Go buy milk|Grocery]]@@
<span class="secret">[[Go buy milk|Grocery]]</span>

/* `data-passage` bearing anchor. */
@@.secret;<a data-passage="Grocery">Go buy milk</a>@@
<span class="secret"><a data-passage="Grocery">Go buy milk</a></span>

Works perfectly, thank you!

I even tried those other wraps to get it to work, I was missing that “a” in the style.