No need for a macro.
To properly order your repeater results by the order in the content tree use NodeLevel, NodeOrder, NodeName
in the order by property. Then I believe you can simply use `<%# (DataItemIndex + 1) %> in your transformation to get the results you're looking for. DataItem index is a zero based index which is why I added 1 to it.