Tweego v2.1.1
SugarCube v2.37.0-alpha.18+10004
What’s the briefest way to declare optionally visible text in-line with the rest of the passage while a story is being written?
I’ve found quite a few discussions of very similar topics, but none seem to be exactly what I’m trying to do.
Some background:
I’m writing a story in which I’d like the reader to be able to select how many viewpoints are visible, depending on whether the global variable $POV has been set to be Single, Multiple or Omnicient. I’m using Sugarcube’s Setting API to set the variable. That part seems to be working fine.
I do not want to put the optionally visible text in a separate passage.
Of course, I can control the visibility in a long-winded way by using something like
<<if $m>>
<div class="...">
optionally visible text
</div>
<</if>>
However, I’d like to drastically reduce the amount of typing that I have to do, with both the variable name and the <div class...
being provided by the macro instead of typing them myself.
For example, I’d like to write passages containing something like
Some text which is visible at all times.
<<ifm>>
Some optionally visible text (using div and class to select a different font, etc) which can be seen when multiple POVs have been requested. That is, when $POV is "Multiple".
<</ifm>>
More text which is visible at all times.
Unfortunately, my knowledge of JavaScript is, shall we say, less than minimal.
My first thoght was to define a macro named <<ifm>>
which declares an initial <div class="...">
and another macro named <</ifm>>
provide the </div>
(as well as whatever other closures might be appropriate.)
I’m sure Sugarcube JS developers are laughing at thie
“Of course” I immediately encountered two problems with this plan:
- the first macro generated an error complaining that there was no
</div>
- a slash (/) doesn’t seem to be allowed in the name of a macro (
<</ifm>>
)
What’s the best way to do this?
Thanks for whatever help you can provide.