Here’s a good rule-of-thumb:
If you are passing in a macro parameter that comes from USER input, assume that it can contain ANY combination of characters (including single, double, or tripled-double quotes). This is because users can type in those quote characters, even if they wouldn’t really make any sense for the intended use-case.
In addition to the """$param$"""
case, you should also be careful when using filteroperator[$param$]
within filter syntax, because a user could enter an errant [
or ]
in their input, which would then break the filter syntax.
For \define
macros, you can generally avoid both of these situations by using <<__param__>>
(or <__param__>
in filters). For \procedure
“macros”, you can use <<param>>
(or <param>
in filters) to accomplish the same thing.
…and, for use-cases where you need to construct a text value with added literal text as prefix or suffix, you can even do something like the following to avoid using ANY kind of quotes or square brackets to set a variable:
\define mymacro(someparam)
\define somevariable() before$(someparam)$after
...
and then refer to <<somevariable>>
(or <somevariable>
in filters) to use the constructed value.
edit: in the above example, the reference to $(someparam)$
should be $someparam$
, like this:
\define somevariable() before$someparam$after
enjoy,
-e