There is somethingI don’t understand about the behaviour of the pretty_print function (or is it a method??)

 

I work exclusively with linguistically annotated texts where every token is wrapped in a <w> element. And pretty_print does a nice job with it.  I often edit these files, updating, splitting, joining, or deleting particular element. If I create another element and use ‘addnext’ to insert it as a right sibling, pretty_print fails and doesn’t print it in a new line. Something like

 

            <w lemma="the" pos="d" xml:id="b2afn-048-a-0570" ana="the/d">The</w>
           
<w xml:id="b2afn-048-a-0580" lemma="" pos="zz" ana="/zz"></w>

 

Becomes

 

 <w lemma="there" pos="av" xml:id="b2afn-048-a-0570" ana="the/d">There</w>
           
<w xml:id="b2afn-048-a-0580" lemma="be" pos="vvb" ana="/zz" >be</w><w xml:id="b2afn-048-a-0581" lemma="n2" pos="n2" reg="ravens">rauyns</w>

 

As I write this, it occurs to me that this may have nothing with pretty_print but with what addnext does or doesn’t do.  But is there a routine that would guarantee that  newly inserted element would by default display with the same indentation as its left sibling?

 

MM