I have an HTML page with some textual spans marked up something like this:
... p50 ...
You can use this library: just annotate your SVG lines with the ids of the source & target element. It uses MutationObserver to observe changes in the connected elements.