Escaping Substitutions - PGML

From WeBWorK_wiki
Jump to navigation Jump to search

Escaped Substitutions

When a variable or command is substituted into a problem in PGML, it will be inserted so that all the characters in the substitution will appear in the problem (special HTML and TeX chacaters and PGML command characters included). For example:

 $a = "[:x:]", $b = "<b>bold</b>"; $c = "25%";
  * [$a] (PGML specials not processed)
  * [$b] (HTML specials display verbatim)
  * [$c] (TeX specials not processed)

should produce a list like the following

 * [:x:] (PGML specials not processed)
 * <b>bold</b> (HTML specials display verbatim)
 * 25% (TeX specials not processed)

in both screen and hardcopy output.

Direct Substitutions

You can prevent the special characters from being escaped by adding a star after the substitution. This will cause the value of the variable to be inserted into the output directly with no additional processing.

 Escaped: [$BSMALL] not small [$ESMALL]  
 Verbatim: [$BSMALL]* small [$ESMALL]*

should produce

 Escaped: <SMALL> not small </SMALL>
 Verbatim:  small 

Note that the requirements for hardcopy output differ from those for screen output, so you need to be sure that your values are appropriate for the current output mode. This is most useful for the variables predefined by WeBWorK, like the $BSMALL and $ESMALL values in the example above, as these are set properly according to the active display mode.

PGML-Processed Substitutions

Sometimes the contents of a variable may contain commands that you want to have processed by PGML after the value is inserted into the text. You can request that PGML interprets the contents of the variable by putting two stars after it rather than just one.

 $pgml = "more PGML math: [:x:], and some *bold* text";
 An insertion with [$pgml]** in it.

will generate

 An insertion with more PGML math: x, and some bold text in it.

With no stars (or one star), you would get

 An insertion with more PGML math: [:x:], and some *bold* text in it.