Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JATS: internal identifier #887

Open
rgieseke opened this issue Mar 30, 2021 · 0 comments
Open

JATS: internal identifier #887

rgieseke opened this issue Mar 30, 2021 · 0 comments

Comments

@rgieseke
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant