Wikification & a javascript macro

Hi. I have this:

\define color-extract()
<$set name="hex" value="<$macrocall $name=colour name=<<colourName>> mode=inline/>">

This outputs hex codes with a preliminary “#” when I call it by itself.

When I try to pipe it into my JS macro as the value of a parameter, I seem to be getting it interpreted as “1. 000000”.

Here is how I am referencing it:

<$macrocall $name="hex_to_hsl" hex=<<color-extract>> aspect="hue" />

I’ve tried adding different output instructions in various locations but this continues to elude me. Do I need to add the equivalent of “rules only” to my JS macro?

1 Like

Try this:

<$wikify name="color-extract" text="<$macrocall $name=colour name=<<colourName>> mode=inline/>">
<$macrocall $name="hex_to_hsl" hex=<<color-extract>> aspect="hue" />


  • Macros are not functions. They don’t “render and return”. They only perform substitutions for “$paramname$” (parameter values passed into the macro) and “$(variablename)$” (variables defined outside the macro). Then the literal content of the macro is “returned” for further processing in the calling context.

  • When the returned macro content (or a variable containing that content) is displayed in a wikitext context, it is rendered, producing the final output (e.g., a hex code with a # prefix). However, if that same macro content is used as the value of a widget parameter (e.g., hex=<<color-extract>>) then the macro is NOT rendered, and its value is simply passed into the widget “as-is”.

  • Thus, there is no benefit to using your color-extract macro. Instead, to get the actual results of the “colour” macrocall, use the $wikify widget to store the output in a variable , and then you can reference that variable as a widget parameter value (e.g., hex=<<color-extract>>)

hope this explanation helps…