Any further documentation for @if .. [@then] ... [@else ...] rules available?

Jan 8, 2016 at 5:46 AM
Edited Jan 8, 2016 at 5:46 AM
Looking into src/expression.kk shows quiet a few undocumented expression things like == and ~~, as well as some missing hints on writing @if with things like @then and @else (which is what I am now really curious about since I can't come up with any working usages of them.)
Jan 8, 2016 at 7:15 PM
ah you are discovering Madoko secrets already :-)

The reason these things are not yet documented is that the design is not really stable yet and things may still change.
I guess I should add a little appendix with 'undocumented' features :-)
Anyway, the ~~ can be used for regular expression matching, as in:
@if html and not(cite-style~~/^(numeric|super|False)\b/i) {
where I generally use @if but the official CSS syntax is @supports. Inside a replacement rule, like replace, before, and after, you can use also a @if .. @then ... @else .. expression to replace with text based on a condition, i.e.
bibitem {
  replace   : '@if (bib-search-url!="") and (searchterm!="") @then "&source; [&mglass;](http://&bib-search-url;/search?q=&searchterm;){.bibsearch}"';
You can find more examples in the prelude.mdk file. However, things may still change. For example, I think it would be nice to support conditional expressions for any attribute and not just replacers. The @if syntax is also somewhat ad-hoc and perhaps we need to come up with something better. etc. Similary, the == is equivalent to = or : in CSS conditionals but that is really superfluous, just like @if versus @supports: they are just there because I find them more natural to write but I guess I should stick to whatever CSS does. etc.