[LON-CAPA-users] More elegant conditional text?

Gerd Kortemeyer lon-capa-users@mail.lon-capa.org
Thu, 7 Feb 2008 19:32:20 -0500


On Feb 7, 2008, at 6:51 PM, lucasm@ohio.edu wrote:

> $array[1] = &xmlparse("<m>$p=mv$</m>");
> for example (untested).

To make the &xmlparse() print correctly, you also need the <display>- 
tag. Sort of sucks. It's easier to use the <parse>-tag. The example  
below shows both versions in action:

<script type="loncapa/perl">
$array[1] = '<m>$E=mc^2$</m>';
$array[2] = &xmlparse('<m>$\nabla E=\varrho/\varepsilon_0$</m>');
<startouttext />It is <parse>$array[1]</parse>, but also <display> 
$array[2]</display> - strange.<endouttext />

I'd recommend using the <parse>-incantation (which is newer than  
&xmlparse()). One of these days, we'll document all of these magic  
incantations properly ...

BTW, one has to use single quotes, or Perl will start to evaluate the  
$p in "<m>$p=..."

- Gerd.