<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Scienco.org &#187; Google Wave</title>
	<atom:link href="http://www.scienco.org/category/google-wave/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scienco.org</link>
	<description>Life&#039;s too short to be unenthusiastic</description>
	<lastBuildDate>Thu, 07 Jul 2011 13:47:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<atom:link rel="next" href="http://www.scienco.org/category/google-wave/feed/?page=2" />

		<item>
		<title>Watexy will be discontinued - please take action with your waves</title>
		<link>http://www.scienco.org/2010/watexy-will-be-discontinued-please-take-action-with-your-waves/</link>
		<comments>http://www.scienco.org/2010/watexy-will-be-discontinued-please-take-action-with-your-waves/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 07:40:23 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Robots]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Watexy]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=262</guid>
		<description><![CDATA[Dear users, It is with sadness that I have to inform you that Watexy will be discontinued. This is a direct consequence of Google pulling the plug on Google Wave (see e.g. http://digihub.theage.com.au/node/1792). Watexy (and associated web-service) gets deleted on 31st of August 2010. I'm very sorry, but hosting the bot is quite expensive, so [...]]]></description>
			<content:encoded><![CDATA[<p>Dear users,</p>
<p>It is with sadness that I have to inform you that Watexy will be discontinued. This is a direct consequence of Google pulling the plug on Google Wave (see e.g. <a href="http://digihub.theage.com.au/node/1792">http://digihub.theage.com.au/node/1792</a>).</p>
<p>Watexy (and associated web-service) gets deleted on 31st of August 2010.</p>
<p>I'm very sorry, but hosting the bot is quite expensive, so I don't see much point in making the deficit any bigger when Google Wave is going to close anyway. And I have to remind you that Google Wave has always been a beta, so the risk of this happening has been present all the time.</p>
<p>Deleting Watexy and associated web-service means that all your waves with Latex-images/-equations will be useless; the images will not appear any longer. This means that you either have to print the waves before 31st of August 2010 or use the history functionality to get back to the Latex-codes.</p>
<p>I am very sorry for this but I see no other opion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2010/watexy-will-be-discontinued-please-take-action-with-your-waves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WatexyML - Google Wave Robot to convert Latex code to MathML - almost ready</title>
		<link>http://www.scienco.org/2010/matexy-google-wave-robot-to-convert-latex-code-to-mathml-almost-ready/</link>
		<comments>http://www.scienco.org/2010/matexy-google-wave-robot-to-convert-latex-code-to-mathml-almost-ready/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 07:05:33 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Robots]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[MathML]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Watexy]]></category>
		<category><![CDATA[WatexyML]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=245</guid>
		<description><![CDATA[I've been working on a robot just like Watexy, but instead of converting Latex to images, it should convert to MathML-fonts. And I'm actually quite far with the robot, so I assume that something will be ready within a couple of days (or maybe a week). Stay tuned! Oh - and I removed the ads [...]]]></description>
			<content:encoded><![CDATA[<p>I've been working on a robot just like Watexy, but instead of converting Latex to images, it should convert to MathML-fonts. And I'm actually quite far with the robot, so I assume that something will be ready within a couple of days (or maybe a week). Stay tuned!</p>
<p>Oh - and I removed the ads on the site. They was indeed annoying! I hope that you will help the development and server expenses by donating a bit if you can afford it. And thanks to those who already donated - it's much appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2010/matexy-google-wave-robot-to-convert-latex-code-to-mathml-almost-ready/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Watexy version 14 â€“ with both inline and display math mode</title>
		<link>http://www.scienco.org/2009/watexy-version-14-%e2%80%93-with-both-inline-and-display-math-mode/</link>
		<comments>http://www.scienco.org/2009/watexy-version-14-%e2%80%93-with-both-inline-and-display-math-mode/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 23:15:01 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Robots]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Watexy]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=241</guid>
		<description><![CDATA[Now version 14 of watexy@appspot.com is released. $ $x$ $ makes an inline equation (with the $-signs immediately following each other and not with a space as here). makes an equation in "display math mode", i.e. centred on its own line. Edit by clicking at the equation (the image). There are still a few misbehaviours/new [...]]]></description>
			<content:encoded><![CDATA[<p>Now version 14 of watexy@appspot.com is released.</p>
<p>$ $x$ $ makes an inline equation (with the $-signs immediately following each other and not with a space as here).<br />
<p style='text-align:center;'><span class='MathJax_Preview'><img src='http://www.scienco.org/wp-content/plugins/latex/cache/tex_13b71563c527e23b0f330a8655e1d21c.gif' style='' class='tex' alt=" 4 + 5  " /></span></p> makes an equation in "display math mode", i.e. centred on its own line. Edit by clicking at the equation (the image).</p>
<p>There are still a few misbehaviours/new feature suggestions:</p>
<ul>
<li>Inline equations still doesn't support &lt; and &gt;</li>
<li>It's still not possible to edit the inline equations</li>
<li>Have an align environment so that several equations can be shown underneath each other</li>
<li>The height of the equation in display math mode doesn't always adjust automatically, so it may be necessary to either click it to edit and the press cancel or view another wave and go back to the original one</li>
<li>The history of how an equations is changed (editing by clicking on it) is not recorded, so for know it's not possible to track changes to a single equations. Yet.</li>
</ul>
<p>I'm of course still working to fix these things, but it might not be solved until January because I'm going to travel the rest of the year.</p>
<p>Thanks a lot for your support and all the feedback. Please continue to comment on how the robot is made, bugs, and suggestions! I'm also on Twitter at <a href="http://twitter.com/mikldk">http://twitter.com/mikldk</a>.</p>
<p>A last request: If you can afford, please donate money to support my work and expenses. You'll find the donate-button in the upper right corner of this page. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2009/watexy-version-14-%e2%80%93-with-both-inline-and-display-math-mode/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Watexy-test (with edit and working &lt; and &gt;)</title>
		<link>http://www.scienco.org/2009/watexy-test-with-edit-and-working-and/</link>
		<comments>http://www.scienco.org/2009/watexy-test-with-edit-and-working-and/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 01:45:28 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Robots]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Watexy]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=233</guid>
		<description><![CDATA[I'm a new version of Watexy with the possibility to edit equations and fixes the bug with &#60; and &#62; not working. The testing-robot is: watexy-test@appspot.com It only works in wave.google.com and not in wavesandbox.com for some reason. I hope you'll take the time to give it a try and some feedback to improve it.]]></description>
			<content:encoded><![CDATA[<p>I'm a new version of Watexy with the possibility to edit equations and fixes the bug with &lt; and &gt; not working.</p>
<p>The testing-robot is:<br />
watexy-test@appspot.com</p>
<p><span style="text-decoration: line-through;">It only works in wave.google.com and not in wavesandbox.com for some reason.</span></p>
<p>I hope you'll take the time to give it a try and some feedback to improve it.</p>
<p><a href="http://www.scienco.org/wp-content/watexy-test.PNG"><img class="aligncenter size-full wp-image-234" title="watexy-test" src="http://www.scienco.org/wp-content/watexy-test.PNG" alt="watexy-test" width="536" height="416" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2009/watexy-test-with-edit-and-working-and/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Watexy version 12 - now supporting multiple equations in one blip</title>
		<link>http://www.scienco.org/2009/watexy-version-12-now-supporting-multiple-equations-in-one-blip/</link>
		<comments>http://www.scienco.org/2009/watexy-version-12-now-supporting-multiple-equations-in-one-blip/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 00:00:52 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Robots]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Watexy]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=231</guid>
		<description><![CDATA[First of all, thanks for the feed-back in [1]. I've now fixed three things: 1) It's now possible to put more than one equation in a blip, and they all get nicely/properly displayed, thanks to Michael, post 18 in [1] for a possible solution 2) Instead of using http://www.forkosh.dreamhost.com/mathtex.cgi , I've now installed the program [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, thanks for the feed-back in [1].</p>
<p>I've now fixed three things:<br />
1) It's now possible to put more than one equation in a blip, and they all get nicely/properly displayed, thanks to Michael, post 18 in [1] for a possible solution<br />
2) Instead of using http://www.forkosh.dreamhost.com/mathtex.cgi , I've now installed the program on one of my own servers (thanks a lot for both the software and the service)<br />
3) Multi-line is supported, such that the equation can be written over multiple lines and still be matched correctly</p>
<p>Please do not hesitate to comment this version as well!</p>
<p>By the way, I'm sorry for the delay with this new version. My life as an exchange student in Australia has been a bit hectic with all the travelling besides the studies.</p>
<p>[1]: http://www.scienco.org/2009/watexy-latex-robot-for-google-wave/</p>
<p>The new code is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Python reference:</span>
<span style="color: #808080; font-style: italic;"># http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Shortcut to the important OpBasedDocument</span>
<span style="color: #808080; font-style: italic;"># http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.ops.OpBasedDocument-class.html</span>
&nbsp;
__author__ = <span style="color: #483d8b;">'mikl@mikl.dk (Mikkel Meyer Andersen)'</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> events
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> model
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> robot
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> document
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> OnRobotAdded<span style="color: black;">&#40;</span>properties, context<span style="color: black;">&#41;</span>:
  <span style="color: #483d8b;">&quot;&quot;&quot;Invoked when the robot has been added.&quot;&quot;&quot;</span>
  root_wavelet = context.<span style="color: black;">GetRootWavelet</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  root_wavelet.<span style="color: black;">CreateBlip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">GetDocument</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">SetText</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hi. My name is Watexy and I'm here to help you presenting Latex in waves. Just put the latex between <span class='MathJax_Preview'><img src='http://www.scienco.org/wp-content/plugins/latex/cache/tex_0060636b449d1da5a8581bfee180f0c2.gif' style=' padding-bottom:2px;' class='tex' alt=" and " /></span>, e.g. <span class='MathJax_Preview'><img src='http://www.scienco.org/wp-content/plugins/latex/cache/tex_b438f8b66349074cc5c273fd905430cb.gif' style=' padding-bottom:2px;' class='tex' alt="2+2=5" /></span>.&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> reversed_iterator<span style="color: black;">&#40;</span><span style="color: #008000;">iter</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">reversed</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">iter</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> OnBlipSubmitted<span style="color: black;">&#40;</span>properties, context<span style="color: black;">&#41;</span>:
  <span style="color: #483d8b;">&quot;&quot;&quot;Invoked when a blip has been added.&quot;&quot;&quot;</span>
  blip = context.<span style="color: black;">GetBlipById</span><span style="color: black;">&#40;</span>properties<span style="color: black;">&#91;</span><span style="color: #483d8b;">'blipId'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> 
  blip_text_view = blip.<span style="color: black;">GetDocument</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  matches = <span style="color: #dc143c;">re</span>.<span style="color: black;">finditer</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\$</span><span style="color: #000099; font-weight: bold;">\$</span>(.+?)<span style="color: #000099; font-weight: bold;">\$</span><span style="color: #000099; font-weight: bold;">\$</span>'</span>, blip_text_view.<span style="color: black;">GetText</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #dc143c;">re</span>.<span style="color: black;">DOTALL</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #483d8b;">&quot;&quot;&quot;
  Reverse list such that the last items will be changed first, such that
  the positions for the first items doesn't change
  &quot;&quot;&quot;</span>
  matches = reversed_iterator<span style="color: black;">&#40;</span>matches<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">for</span> m <span style="color: #ff7700;font-weight:bold;">in</span> matches:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    The +/- 2 is because of the length of the $$'s. 
    If not removed, the loop will run infintely! 
    &quot;&quot;&quot;</span>
    blip_text_view.<span style="color: black;">DeleteRange</span><span style="color: black;">&#40;</span>document.<span style="color: black;">Range</span><span style="color: black;">&#40;</span>m.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">2</span>, m.<span style="color: black;">end</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>+<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    image = document.<span style="color: black;">Image</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://meyer.fm/cgi-bin/mathtex.cgi?'</span> + m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>, caption=m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    blip_text_view.<span style="color: black;">InsertElement</span><span style="color: black;">&#40;</span>m.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">2</span>, image<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
  myRobot = robot.<span style="color: black;">Robot</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'watexy'</span>,
      image_url=<span style="color: #483d8b;">'http://watexy.appspot.com/assets/icon.png'</span>,
      version=<span style="color: #483d8b;">'12'</span>,
      profile_url=<span style="color: #483d8b;">'http://watexy.appspot.com/'</span><span style="color: black;">&#41;</span>
  myRobot.<span style="color: black;">RegisterHandler</span><span style="color: black;">&#40;</span>events.<span style="color: black;">WAVELET_SELF_ADDED</span>, OnRobotAdded<span style="color: black;">&#41;</span>
  myRobot.<span style="color: black;">RegisterHandler</span><span style="color: black;">&#40;</span>events.<span style="color: black;">BLIP_SUBMITTED</span>, OnBlipSubmitted<span style="color: black;">&#41;</span>
  myRobot.<span style="color: black;">Run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2009/watexy-version-12-now-supporting-multiple-equations-in-one-blip/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Watexy - Latex robot for Google Wave</title>
		<link>http://www.scienco.org/2009/watexy-latex-robot-for-google-wave/</link>
		<comments>http://www.scienco.org/2009/watexy-latex-robot-for-google-wave/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 00:06:04 +0000</pubDate>
		<dc:creator>Mikkel Meyer Andersen</dc:creator>
				<category><![CDATA[Robots]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Watexy]]></category>

		<guid isPermaLink="false">http://www.scienco.org/?p=216</guid>
		<description><![CDATA[I finally got access to a Google Wave sandbox account, making it possible to start experimenting. The first thing I made was a Latex robot. By adding the robot, it's possible to write Latex in Waves. Afterwards, simply by putting Latex between two $'s: Probably the document needs some kind of updatering > Even though [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got access to a Google Wave sandbox account, making it possible to start experimenting. The first thing I made was a Latex robot. By adding the robot, it's possible to write Latex in Waves. Afterwards, simply by putting Latex between two $'s:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #8020E0; font-weight: normal;"><span class='MathJax_Preview'><img src='http://www.scienco.org/wp-content/plugins/latex/cache/tex_5c0476bb8a145db4a917ea58faf42ffa.gif' style=' padding-bottom:2px;' class='tex' alt="<span style="color: #800000; font-weight: normal;">\lim</span>_<span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">n <span style="color: #800000; font-weight: normal;">\to</span> <span style="color: #E02020; ">\</span><span style="color: #800000;">infty</span></span><span style="color: #E02020; ">}</span> <span style="color: #E02020; ">\</span><span style="color: #800000;">frac</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">n</span>} = 0$</span>$</pre></div></div>

<p>Watexy then changes the Wave and inserts the Latex as an image instead of the text.</p>
<p>You can try it yourself by adding watexy [this-funny-curly-a] appspot.com to your Wave-conversations. <a href="http://www.scienco.org/wp-content/watexy-v009.zip">You can download the source here.</a></p>
<p>There's still a quite big bug: It's only the first Latex-image that gets substituted correctly. The following gets inserted some positions wrong, and the deletion of the text isn't correct neither. But the images itself are correct, only the substitution isn't working properly. But I'm working on that!</p>
<p>The more technical part: the robot is written in Python, hence using the Google Wave Python API. It's the first time I've tried that (thought it was a good possibility to learn it). The robot basically works by getting triggered when a new blip is submitted. Then it searches for Latex-code in that and substitutes it with pictures. Although the code is quite simple, it shows some very basic concepts on how to alter/change the contents of Waves on-the-fly (deleting text and inserting images, but it could be other things as well) with robots. The Latex-source-to-image is done by the <a title="http://www.forkosh.dreamhost.com/source_mathtex.html#webservice" href="http://www.forkosh.dreamhost.com/source_mathtex.html#webservice">http://www.forkosh.dreamhost.com/source_mathtex.html#webservice</a> service.</p>
<p>The core Python comprising the robot is this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Python reference:</span>
<span style="color: #808080; font-style: italic;"># http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html</span>
 
<span style="color: #808080; font-style: italic;"># Shortcut to the important OpBasedDocument</span>
<span style="color: #808080; font-style: italic;"># http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.ops.OpBasedDocument-class.html</span>
 
<span style="color: #483d8b;">""" 
Known bugs:
- From (and including) the second Latex-fragment, the positioning gets wrong
  > Probably the document needs some kind of updatering
  > Even though it's a bit strange since the re matches all the Latex correctly
"""</span>  
 
__author__ = <span style="color: #483d8b;">'mikl@mikl.dk (Mikkel Meyer Andersen)'</span>
 
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
 
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> events
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> model
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> robot
<span style="color: #ff7700;font-weight:bold;">from</span> waveapi <span style="color: #ff7700;font-weight:bold;">import</span> document
 
<span style="color: #ff7700;font-weight:bold;">def</span> OnRobotAdded<span style="color: black;">(</span>properties, context<span style="color: black;">)</span>:
  <span style="color: #483d8b;">"""Invoked when the robot has been added."""</span>
  root_wavelet = context.<span style="color: black;">GetRootWavelet</span><span style="color: black;">(</span><span style="color: black;">)</span>
  root_wavelet.<span style="color: black;">CreateBlip</span><span style="color: black;">(</span><span style="color: black;">)</span>.<span style="color: black;">GetDocument</span><span style="color: black;">(</span><span style="color: black;">)</span>.<span style="color: black;">SetText</span><span style="color: black;">(</span><span style="color: #483d8b;">"Hi. My name is Watexy and I'm here to help you presenting Latex in waves. Just put the latex between " /></span> and <span class='MathJax_Preview'><img src='http://www.scienco.org/wp-content/plugins/latex/cache/tex_b19d4096d8de09fa70c205be7b80fd00.gif' style=' padding-bottom:2px;' class='tex' alt=", e.g. " /></span>2+2=5<span class='MathJax_Preview'><img src='http://www.scienco.org/wp-content/plugins/latex/cache/tex_36547c74d482d39f7fe4d7a350f49819.gif' style=' padding-bottom:2px;' class='tex' alt=". This robot uses the http://www.forkosh.dreamhost.com/source_mathtex.html#webservice service."</span><span style="color: black;">)</span>
 
<span style="color: #ff7700;font-weight:bold;">def</span> OnBlipSubmitted<span style="color: black;">(</span>properties, context<span style="color: black;">)</span>:
  <span style="color: #483d8b;">"""Invoked when a blip has been added."""</span>
  blip = context.<span style="color: black;">GetBlipById</span><span style="color: black;">(</span>properties<span style="color: black;">[</span><span style="color: #483d8b;">'blipId'</span><span style="color: black;">]</span><span style="color: black;">)</span> 
  blip_text_view = blip.<span style="color: black;">GetDocument</span><span style="color: black;">(</span><span style="color: black;">)</span>
 
  latex_regex = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">(</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\$</span><span style="color: #000099; font-weight: bold;">\$</span>(.+?)<span style="color: #000099; font-weight: bold;">\$</span><span style="color: #000099; font-weight: bold;">\$</span>'</span><span style="color: black;">)</span>
  m = latex_regex.<span style="color: black;">search</span><span style="color: black;">(</span>blip_text_view.<span style="color: black;">GetText</span><span style="color: black;">(</span><span style="color: black;">)</span><span style="color: black;">)</span>
 
  <span style="color: #483d8b;">""" 
  Only replace one Latex-fragment at a time, because replaceing one fragment
  changes the text positions in the rest. That's why re.finditer isn't used.  
  """</span>
  <span style="color: #ff7700;font-weight:bold;">while</span> m <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span>:
    <span style="color: #483d8b;">"""
    The +/- 2 is because of the length of the " /></span>'s. 
    If not removed, the loop will run infintely! 
    &quot;&quot;&quot;</span>
    blip_text_view.<span style="color: black;">DeleteRange</span><span style="color: black;">&#40;</span>document.<span style="color: black;">Range</span><span style="color: black;">&#40;</span>m.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">2</span>, m.<span style="color: black;">end</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>+<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    image = document.<span style="color: black;">Image</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.forkosh.dreamhost.com/mathtex.cgi?'</span> + m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>, caption=m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    blip_text_view.<span style="color: black;">InsertElement</span><span style="color: black;">&#40;</span>m.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">2</span>, image<span style="color: black;">&#41;</span>    
    m = latex_regex.<span style="color: black;">search</span><span style="color: black;">&#40;</span>blip_text_view.<span style="color: black;">GetText</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
  myRobot = robot.<span style="color: black;">Robot</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'watexy'</span>, 
      image_url=<span style="color: #483d8b;">'http://watexy.appspot.com/assets/icon.png'</span>,
      version=<span style="color: #483d8b;">'9'</span>,
      profile_url=<span style="color: #483d8b;">'http://watexy.appspot.com/'</span><span style="color: black;">&#41;</span>  
  myRobot.<span style="color: black;">RegisterHandler</span><span style="color: black;">&#40;</span>events.<span style="color: black;">WAVELET_SELF_ADDED</span>, OnRobotAdded<span style="color: black;">&#41;</span>
  myRobot.<span style="color: black;">RegisterHandler</span><span style="color: black;">&#40;</span>events.<span style="color: black;">BLIP_SUBMITTED</span>, OnBlipSubmitted<span style="color: black;">&#41;</span>
  myRobot.<span style="color: black;">Run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.scienco.org/2009/watexy-latex-robot-for-google-wave/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

