### STACK - math notation not being rendered 1st time

Number of replies: 5Just been playing around with STACK again this evening - to ensure that the mathematical notation is being rendered correctly. I've now got the tex filter generating the notation (see http://moodle.org/mod/forum/discuss.php?d=128353) but when I first "try" a question the images aren't displayed (instead of math notation I get a link to texdebug). If I press F5 then any notation is now displayed correctly. It always seems to work second time around.

Has anyone else experienced this problem?

EDIT: I've just spotted that the tex filter is doing this with anything surrounded by single dollars and not double dollars. Is that a clue?

Thanks in advance,

Ian.

### Re: STACK - math notation not being rendered 1st time

### Re: STACK - math notation not being rendered 1st time

Not just double dollars - tex filter should be able to change also < t e x > , [ t e x ] and \ [ tags - editor just changes < : s to < and you know the wiki issue... but you can as well add new delimiters to this file.

I suppose the problem Ian has is connected to cache - tex filter ( file filter/tex/filter.php) checks first in line 111 if selected delimiters do not exist to avoid unnecessary work. If delimiters do exist tex filter replaces all \$ with $ and searches the actual tags to be replaced with images in line 142

If the notation is not in text cache filter adds it to text cache and tex filter also checks if previous images already exist in temporary folder - if not it creates a new gif/png file and another code deletes those temporary folders and files.

I haven't played much with tex filter code but I suspect that something is done in wrong order - I should test Ian's changes myself to know better...

I noticed something similar when I tested a "quickly modified tex/mathml filter" some days ago that should have rendered always mathML for FF and TeX for other browsers using this modified tex filter - it worked ok except tex filter did not always render tex for the first time but did find images the second time page was visited (first image fallback was created with AM.js although I would have thought tex filter had done it in the first place).

### Re: STACK - math notation not being rendered 1st time

Marc: basically I implemented Mauno's suggestion:

You can also change line 111 of filter/tex/filter.php

if (!preg_match(... { //added one more tag (dlnsk)

and

line 142 from the same file

preg_match_all(...

to change delimiters of tex filter.

Check also lines 131 to 134 if you need to replace (double) dollars with some other symbols.

Just looking at this again: I think the problem is just how Mauno describes - except I have no idea how to fix it .

It won't be a problem tomorrow (for demonstration) now I know what the problem is I can explain it away.

Ian.

### Re: STACK - math notation not being rendered 1st time

I am some 16 hours out of sync-lol

Yes, Tex filter can use anything you want for tokens, just meant that dbldollars is default as if one hadn't fiddled filter it would be asciimath giving the grief...

Ian, if you just want to use asciisvg you can.... Simply use that script instead of asciimath. Then leave your Tex filter in native state.....

### Re: STACK - math notation not being rendered 1st time

To be honest, the only reason I wanted the notation rendered with TeX is that I like the way it looks (not much of a reason, I know).

Cheers,

Ian.