Am having an issue that I don't understand.
I have a bot that looks for URLs (regexp matching) and replaces them with an
image.
Here's a code piece:
def OnBlipSubmitted(properties, context):
blip = context.GetBlipById(properties['blipId'])
doc = blip.GetDocument()
m = r.search(doc.GetText())
while m != None:
doc.DeleteRange(document.Range(m.start(0), m.end(0)))
image = getImage(m.group(2))
newimage = document.Image(image.thumb.source, caption=image.title,
width=image.thumb.width, height=image.thumb.height)
doc.InsertElement(m.start(0), newimage)
m = r.search(doc.GetText())
So - I grab the first match - remove it, insert an image then search again -
on the new text.
This works fine for the first URL - it gets it exactly right.
However - if I add the following to a blip:
http://www.example.com/foo/bar bla bla http://www.example.com/bar/foo
I expect
IMG bla bla IMG
I get
IMG bla bIMGfoo
That is - the second one is three characters (always 3) too early both in
start and end. From what I can see - its the values of m.start and m.end
that are at fault. The actual match itself is correct - since the values of
m.group(0) and m.group(2) are exactly right for the input. I'm uncertain as
to why this is - what could be in the text that is confusing it. If anyone
can give me any hints ?
Oh - and while asking - what is the caption param of an Image for? It
certainly doesn't appear in the blip even though it's being set.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Wave API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-wave-api?hl=en
-~----------~----~----~----~------~----~------~--~---