Strategies for handling links between documents when documents are transcluded?

Suppose I have two markdown documents, “a” and “b”, and suppose “b” has a link to document “a” in the form of

[something](x-devonthink-item://B7509BE8-6718-4E83-BE5A-4945BBA3D23F)

Further suppose both “a” and “b” are transcluded into another document, “c”.

Some text.

{{a}}

Some more text.

{{b}}

Finally, let’s convert this “c” to markdown via the menu item DataConvertto Markdown. In the resulting document, the link above ends up as-is, unmodified, even though in the transcluded and merged document, “a” no longer exists. In other words, inter-document links do not end up pointing to content within the merged document “c”.

This behavior makes sense from a technical perspective. However, it would be convenient (at least for some uses of transclusion) if it were possible have links automatically adjusted by DEVONthink to “naturally” end up pointing to the right place inside the merged document “c”. (I understand “right place” may be subjective; for purposes of this discussion, one option would be to put the link destination at the beginning of where the text of “a” is inserted in the merged document.)

DEVONthink does not seem to automatically adjust these link destinations. Is there another way to accomplish it? Perhaps by writing the links in a different, more clever way, or including something inside “a” that will end up in the transcluded result? I bet it could be done by scripting, but before going that far, I wonder if there’s a simpler way.

the link above ends up as-is, unmodified, even though in the transcluded and merged document, “a” no longer exists.

Why would a no longer exist?
Are you manually deleting it?

In other words, inter-document links do not end up pointing to content within the merged document “c”.

That is correct.
An item link isn’t an anchor within another document.
It’s a link to another document.

I tried to make this clear in the description, but I guess it still wasn’t clear enough:

even though in the transcluded and merged document, “a” no longer exists.

In other words, in the merged/transcluded document, there is no “a” per se. Its content has been inserted into “c”, but there is no “document a” inside “c” as a file construct.

The document still exists outside; nothing is deleting it.

I hope this makes more sense now.

Right, and so that’s why I was asking if there’s some more clever way to accomplish the goal, perhaps by including something inside “a” that will end up in the transcluded result.

One idea I started experimenting with is to put

<a name="some-anchor-text"></a>

inside documents being transcluded. The result will be carried into the merged document, so (e.g.) if it’s at the top of document “a”, it will appear inside “c” at the point where “a” is inserted. Markdown links can reference anchors, so inside “b”, one could use

[something](#some-anchor-text)

The downside of this approach is that links only works in the merged document. While working with the individual documents, the links won’t work to go from (e.g.) “b” to “a”.

But maybe I’m not being clever enough …

I don’t see any way around this.
You’re not going to be able to multi-purpose the link. It’s either going to function as an item link or an anchored link but not both.