zotero / citeproc-rs

CSL processor in Rust.
https://cormacrelf.github.io/citeproc-wasm-demo/
Other
73 stars 11 forks source link

Convention to specify a link for bibliography #59

Open danmackinlay opened 4 years ago

danmackinlay commented 4 years ago

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 commented 4 years ago

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:

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.