Link to anchor in another document

I’ve written a migration to import a large number of HTML pages into documents within the CMS. The documents are all chapters and sections of a larger overall document.

They all display fine, but I’m having an issue with anchor links, which work fine when the anchor is on the same page (as per the details given here: https://www.onehippo.org/library/end-user-manual/editing-a-document.html) but all of the documents need to link to the anchors on a single document, which is an appendix of terms referenced throughout the rest of the overall document.

If you add the anchor onto the link via the code (i.e. <a href"appendix#anchor">some anchor</a> the link goes to pagenotfound. Is there a way of allowing links to anchors in other documents?

It seems like a shortcoming at the moment.
I see org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter#rewriteDocumentLink(String, Node, HstRequestContext, Mount) doesn’t care if the href (assumed to be a document path) contains a #.
I think it can be improved. Feel free to file a ticket in https://issues.onehippo.com/projects/HSTTWO.
In the short term, you might also consider implementing a custom content rewriter [1] which trim off #... part before invoking #getDocumentLink(...) and appending it to the result.

Regards,

Woonsan

[1] https://www.onehippo.org/library/concepts/rewriting-rich-text-field-runtime/hst-2-rewriting-rich-text-field-runtime.html