Nov 14
Watexy version 14 – with both inline and display math mode
icon1 Mikkel Meyer Andersen | icon4 November 14, 2009 at 23:15 (UTC) | icon3 35 Comments »
icon3 , , , ,

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).
\[ 4 + 5 \] 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 feature suggestions:

  • Inline equations still doesn’t support < and >
  • It’s still not possible to edit the inline equations
  • Have an align environment so that several equations can be shown underneath each other
  • 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
  • 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.

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.

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 http://twitter.com/mikldk.

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.

Nov 13
Watexy-test (with edit and working < and >)
icon1 Mikkel Meyer Andersen | icon4 November 13, 2009 at 01:45 (UTC) | icon3 13 Comments »
icon3 , , , ,

I’m a new version of Watexy with the possibility to edit equations and fixes the bug with < and > 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.

watexy-test

Nov 11

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 on one of my own servers (thanks a lot for both the software and the service)
3) Multi-line is supported, such that the equation can be written over multiple lines and still be matched correctly

Please do not hesitate to comment this version as well!

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.

[1]: http://www.scienco.org/2009/watexy-latex-robot-for-google-wave/

The new code is as follows:

# Python reference:
# http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html
 
# Shortcut to the important OpBasedDocument
# http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.ops.OpBasedDocument-class.html
 
__author__ = 'mikl@mikl.dk (Mikkel Meyer Andersen)'
 
import re
 
from waveapi import events
from waveapi import model
from waveapi import robot
from waveapi import document
 
def OnRobotAdded(properties, context):
  """Invoked when the robot has been added."""
  root_wavelet = context.GetRootWavelet()
  root_wavelet.CreateBlip().GetDocument().SetText("Hi. My name is Watexy and I'm here to help you presenting Latex in waves. Just put the latex between $$ and $$, e.g. $$2+2=5$$.")
 
def reversed_iterator(iter):
    return reversed(list(iter))
 
def OnBlipSubmitted(properties, context):
  """Invoked when a blip has been added."""
  blip = context.GetBlipById(properties['blipId']) 
  blip_text_view = blip.GetDocument()
 
  matches = re.finditer('\$\$(.+?)\$\$', blip_text_view.GetText(), re.DOTALL)
 
  """
  Reverse list such that the last items will be changed first, such that
  the positions for the first items doesn't change
  """
  matches = reversed_iterator(matches)
 
  for m in matches:
    """
    The +/- 2 is because of the length of the $$'s. 
    If not removed, the loop will run infintely! 
    """
    blip_text_view.DeleteRange(document.Range(m.start(1)-2, m.end(1)+2))
    image = document.Image('http://meyer.fm/cgi-bin/mathtex.cgi?' + m.group(1), caption=m.group(1))
    blip_text_view.InsertElement(m.start(1)-2, image)
 
if __name__ == '__main__':
  myRobot = robot.Robot('watexy',
      image_url='http://watexy.appspot.com/assets/icon.png',
      version='12',
      profile_url='http://watexy.appspot.com/')
  myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded)
  myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted)
  myRobot.Run()