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

Convention to specify a link for bibliography #59

Open
danmackinlay opened this issue Jan 17, 2020 · 1 comment
Open

Convention to specify a link for bibliography #59

danmackinlay opened this issue Jan 17, 2020 · 1 comment

Comments

@danmackinlay
Copy link

As per the suggestion there, this issue is cloned from a citeproc-js issue:

Currently AFAICT CSL is in limbo regardingspecification for hyperlinks in bibliographies and so CSL implementers must invent their own convention for specifying hyperlinks. Is this something we are interested in? Do we need some way of specifying that part or all of a bibliographical entry (such as the whole entry, or the title, or the author name/date or something) should be a hyperlink (either to the URL field or the DOI link)? Currently it seems there is the wrap_url_and_doi process which can be ugly, although of course one can make it look nicer with CSS for HTML output. if one has control of the CSS. There are also macro hacks for LaTeX output; but it seems like some kind of unified approach might be in order?

@cormacrelf
Copy link
Collaborator

cormacrelf commented Jan 19, 2020

Hey guess what, citeproc-rs already has its own version of wrap_url_and_doi! It has a number of shortfalls, and it frankly shouldn't be enabled by default given the state of it:

  • I haven't put proper escaping on it so weird URLs will break
  • haven't implemented it for RTF
  • there isn't an API for supplying flags to the processor at runtime (the way citeproc-js can be configured via JavaScript)
  • won't convert non-link DOIs into proper URLs
  • won't recognise inputs that aren't URLs and refuse to wrap them in a link.

So it's not done in any sense of the word. But if you put a very simple link in there it will get an anchor tag around it in HTML, and the affixes work correctly so <https://google.com> renders correctly.

For reference, the code is roughly in these, three, places

The definition of InlineElement::Anchor with children being nodes rather than a string means it's very easy to support wrapping other output like affixes etc, but I would prefer to avoid adding a feature like this:

<group urlwrap="DOI">
  <text value="doi:" />
  <text variable="DOI" />
</group>

(Output is doi:12345 as opposed to doi:12345.)

Why? Because groups being implicit conditionals means you need to change the definition of an intermediate group, and then add hyperlinks when flattening those groups later. Keeping that inside the <text> element keeps the hyperlinking from being another 'deferred' attribute. That could look like this:

<text url="DOI" include-affixes="true" prefix="doi:" />

text url could be another variant of text variable/value/macro etc. <text variable="title" url="DOI"> for wrappping another variable. I would be cool with that.

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

No branches or pull requests

2 participants