Escaping Substitutions - PGML

From WeBWorK_wiki
Revision as of 18:22, 4 January 2016 by Dpvc (talk | contribs) (Make tags in $b show up rather than be processed.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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%";
 BEGIN_PGML
  * [$a] (PGML specials not processed)
  * [$b] (HTML specials display verbatim)
  * [$c] (TeX specials not processed)
 END_PGML

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.

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

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";
 BEGIN_PGML
 An insertion with [$pgml]** in it.
 END_PGML

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.