0 votes
by (1.3k points)
edited by

Hey, I'm using the macro from the sugarcube page, and I really like it. It does everything I could expect, but I do have one niggle with it. If I have strings like within the choices:

"''perky and promiscuous,'' perhaps what you'd picture on a //svelte little wood nymph// or something"

Then they're rendered just like that, so you see the '' and // and whatnot. It's a pretty technical macro so I'm not about to play with it myself. But, is there some kind of sneaky way to force the macro to render this string properly? Or is is just something I have to live with?

I'm just wondering.


Oh, and it's the same if I use html markup, like with <b> and <i> instead. I just tried.

1 Answer

0 votes
by (68.6k points)
selected by
Best answer

It's only intended to use plain text strings.  Try this version which should allow markup: (untested)

/*! <<cyclinglink>> macro for SugarCube 2.x */
!function(){"use strict";if("undefined"==typeof version||"undefined"==typeof version.title||"SugarCube"!==version.title||"undefined"==typeof version.major||version.major<2)throw new Error("<<cyclinglink>> macro requires SugarCube 2.0 or greater, aborting load");version.extensions.cyclinglinkMacro={major:3,minor:3,revision:2},macros.cyclinglink={handler:function(a,b,c){function toggleText(w){w.classList.remove("cyclingLinkInit"),w.classList.toggle(rl+"Enabled"),w.classList.toggle(rl+"Disabled"),w.style.display="none"===w.style.display?"inline":"none"}var rl="cyclingLink";switch(c[c.length-1]){case"end":var end=!0;c.pop();break;case"out":var out=!0;c.pop()}var v=null;c.length&&"$"===c[0][0]&&(v=c[0].slice(1),c.shift());var h=State.variables;if(!out||!v||""!==h[v]){var l=insertElement(a,"a");l.className="link-internal cyclingLink",l.setAttribute("data-cycle",0);for(var i=0;i<c.length;i++){var on=i===(v?Math.max(c.indexOf(h[v]),0):0),d=insertElement(null,"span",null,"cyclingLinkInit cyclingLink"+(on?"En":"Dis")+"abled");on?(v&&(h[v]=c[i]),l.setAttribute("data-cycle",i)):d.style.display="none",$(d).wiki(c[i]),on&&end&&i===c.length-1?l.parentNode.replaceChild(d,l):l.appendChild(d)}jQuery(l).ariaClick(function(){var t=this.childNodes,u=this.getAttribute("data-cycle")-0,m=t.length;if(toggleText(t[u]),u+=1,out&&u===m?v&&(h[v]=""):(u%=m,v&&(h[v]=c[u])),(end||out)&&u===m-(end?1:0)){if(!end)return void this.parentNode.removeChild(this);var n=this.removeChild(t[u]);return n.className=rl+"End",n.style.display="inline",void this.parentNode.replaceChild(n,this)}toggleText(t[u]),this.setAttribute("data-cycle",u)})}}}}();


by (1.3k points)
Yeah, that totally works! Or at least works with //. I can easily test for that, but not the bold stuff. But, if it works, it works.

So, I think that version is good. I'll leave it in and test it further, as I go. If I have any issues, I'll reply to this thread. Thanks for this! It's really cool.