Skip to content

JATS: internal identifier #887

Description

@rgieseke

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions