I'm writing app to convert data contained mostly in xml files to static html. At any point in xml, there may be a nested tag like this one:
<t:latex-object url='%28-3%29%5E%7B2%7D%3D3%5E%7B2%7D'><![CDATA[(-3)^{2}=3^{2}]]></t:latex-object>
I have to take the url, generate latex image from it, and replace this tag with img src in html.
What I'm doing right now, is going through entire xml file and generating html output leaving this tags as they are. Next, I wanted to go through entire output, find all occurrences of this tag, generate image for each one, and replace them. But, since url attribute is different every time I can't use replace() function.
I was thinking about using regex, but all I got so far is list of all url attributes and a headache. I was thinking about writing regex which would replace all latex tags with just their url attribute so I could just iterate through my list of urls and replace them with generated images.
Does this kind of approach make any sense? I feel like there should be easier way to do it, not to mention I've spent over an hour trying to write such regex with poor results.