leo-editor/leo-editor — pull request #11 by Armagedoom (2014-03-07 11:59:51+00:00)
Title: xPath-like UNL's

Given an outline:

a
b
c
b
d

Their new UNLs will be:

a[0][0]
b[0][0]
c[1][0]
b[2][1]
d[3][0]

The first integer is the nth of sibling, the second one is the nth of siblings with exact same headers before him.

The reason why [0][0] is included within all parts of UNL's is because this way it wont conflict with user headers ending in [0][0] or any other whatsoever, since the stored UNL for them would be "[0][0][0][0]"
If this wasnt done, that case would lead to contradictions.

Also, since now we have the nth_sibling, it could be done so if the node UNL is not found at all, the path could be reconstructed by sibling position instead.

If this behaviour is desirable, please confirm and I can do that.

Please review the code before pulling, specially the "import re" lines, and generally the "pythonic" way of naming the variables.

The code is tested and works, and its very nice for Leo to be storing and finding nodes even if several repeated ones are before them :dancers: