richardlewis at fastmail.co.uk
Fri Aug 26 12:43:18 CEST 2005
On Fri, 26 Aug 2005 12:13:10 +0200, "Diez B. Roggisch"
<deets at nospam.web.de> said:
> Richard Lewis wrote:
> > I admit I haven't tried very much code yet, but I'm not sure how I'm
> > going to handle situations like: the user wants to insert a link in the
> > middle of a paragraph. How can I use the DOM to insert a node into the
> > middle of some text? Am I right in thinking that the DOM will reference
> > a whole text node but nothing smaller?
> You have to split the text-node, and add the two resulting noedes
> together with the new link-node (or whatever node you want there, can be
> a whole tree) in the correct order to the parent of the two node. If
> unsure what that means, create two simple documents and parse these to
> dom to see how that works.
Thanks. I was kind of worried it might be like that!
I'm implementing a Cursor class now which keeps track of the current
parent Element, text node and character position so that I can easily (I
hope ;-) work out where the splitting and inserting needs to occur. Wish
More information about the Python-list