Currently internal links are partly broken by not using this function in all cases i believe:
/**
* Decode a JATS internal identifier.
*
* This function normalizes an id so that it can not be confused with a URL.
* This is necessary for issues such as [this](https://github.com/stencila/encoda/pull/399#issuecomment-580391161)
* where a `rid` "looked like" a URL and so was treated as such.
* The [`rid` (reference to an identifer)](https://jats.nlm.nih.gov/archiving/tag-library/1.1/attribute/rid.html)
* attribute is intended to be used for internal identifiers within the document.
*/
function decodeInternalId(id: string | null): string | undefined {
if (id === null) return undefined
return id.replace(/\./g, '-')
}
https://github.com/stencila/encoda/blob/master/src/codecs/jats/index.ts#L1654
I'm not sure how this should be handled, but right now only some ids get the replacement.
For example Figure ids are not changed.
It is possible to change internal links the same way while rendering:
if (node.target.startsWith('#')) {
target = target.replace(/\./g, '-')
}
Not sure what the best approach is, should all ids use decodeInternalId, use rids or is there another way to detect/prevent this problem? I'm not sure i fully understood the issue in the linked issue with confusing with a URL.
Currently internal links are partly broken by not using this function in all cases i believe:
https://github.com/stencila/encoda/blob/master/src/codecs/jats/index.ts#L1654
I'm not sure how this should be handled, but right now only some ids get the replacement.
For example Figure ids are not changed.
It is possible to change internal links the same way while rendering:
Not sure what the best approach is, should all ids use
decodeInternalId, userids or is there another way to detect/prevent this problem? I'm not sure i fully understood the issue in the linked issue with confusing with a URL.