I'm struggling a little with the code base of citeproc at the moment,
and would be grateful for any pointers people could give me.
I've got as far as running citeproc to produce a (reasonably) nice
bibliography in HTML. My intext-citations look like....
<span id="kcite-citation-5" kcite-id="ITEM-4">
<span style="text-decoration: underline;">(D’Arcus 2005)
</span>
</span>
This is from the DOM post citeproc processing. One entry from the
bibliography looks like this...
<div class="csl-entry">D’Arcus, Bruce. 2005.
<i>Boundaries of Dissent: Protest and State Power
in the Media Age</i>. Routledge, November 22.</div>
Now I know that I can modify the output format using the output
prototype in formats.js. I've been trying to hunt down where this
substitution happens in code, but my javascript is just not good enough.
So, my question is, can I parameterise this in someway. The basic
problem is that, I want to hyperlink the in-text citation to the
bibliography. The in-text citation gives me enough information to do
this, but in the generated bibliography there is not.
For example, if I have defined the retrieveItem function like so:
var sys = {
retrieveItem: function(id){
return citation_data[id];
},
retrieveLocale: function(lang){
return locale[lang];
}
};
I would like to generate
<a name="ITEM-4">
<div class="csl-entry">D’Arcus, Bruce. 2005.
<i>Boundaries of Dissent: Protest and State Power
in the Media Age</i>. Routledge, November 22.</div>
</a>
where ITEM-4 is the id that would have been passed to retrieveItem.
I'm also trying to hyperlink DOIs in the bibliography, and want to
include outgoing links as well. But one thing at a time.
Phil
Wouldn't it be more appropriate to use an id anchor on the div, and
leave room to expand? E.g. start with:
<div class="csl-entry" id="citeref:d-arcus-2005">D’Arcus, Bruce. 2005.
<i>Boundaries of Dissent: Protest and State Power
in the Media Age</i>. Routledge, November 22.</div>
... then add basic links:
<div class="csl-entry" id="cite:d-arcus-2005">D’Arcus, Bruce. 2005.
<i><a href="[some uri]">Boundaries of Dissent: Protest and State Power
in the Media Age</a></i>. Routledge, November 22.</div>
... and maybe at some point layer in basic RDFa (details unchecked;
just for illlustration):
<div class="csl-entry" id="cite:d-arcus-2005"
property="dc:references" about="[some uri]"
typeOf="bibo:Book">D’Arcus, Bruce. 2005.
<i><a href="[some uri]"><span property="dc:title">Boundaries
of Dissent: Protest and State Power
in the Media Age</span></a></i>. Routledge, November 22.</div>
...?
Bruce
The short answer is probably.
The longer answer is once I have got the basic metadata that I need out
of citeproc and I can do any processing I like in independent
javascript. In terms of reducing dependencies between my code and
citeproc, it seemed to me that the best solution was to get the basic
info out of citeproc then do the rest externally.
For my money, I would do
<div class="csl-entry" citeproc-id="CITE-4">Blah</div>
This gives me the key information that I need. I can anchor this however
I choose then. More over, I have the key to the bib JSON, so if I want
to add more stuff (which I probably will do) then I get that data
structure also.
But at the moment, I have to guess the bibliography entry from the in
text citation. Not somewhere I want to go.
Phil
I'm reasonably far from "getting comfortable" (is it really true that to
build citeproc-js I have to run a file called "test"?). But there is
nothing like having a need to enable this.
I will try and have another pick through api_bibliography.js and see if
I can work it out!
Phil
Frank
I'm sort of getting my head around this, but I am a bit stuck.
If I understand things correctly, CSL.getBibliographyEntries does adds
tokens to an output queue, at a point when we don't know what the output
format is. So, this code adds a new token representing the bib entry (or
the start of one.
bib_entry = new CSL.Token("group", CSL.START);
bib_entry.decorations = [["@bibliography", "entry"]].concat(this[this.build.area].opt.layout_decorations);
this.output.startTag("bib_entry", bib_entry);
At this point, I have easy access to the bibliographic item being
processed.
Later on, the queue gets run. At this CSL.Output.Queue.prototype.string
takes over. At this point, we know the output format, but we no longer
know the item.
If my understanding is correct, I could stuff any object I like (including
the item) into the CSL.Token object; but this doesn't get passed to the
decorator function -- only "state" and "str" get passed in.
So I'm not really sure how to put these two parts together.
Tips welcome!
Phil
Okay, thanks!
If it is any help, I think my inclination would be to allow the addition
of a standard "what am I" object to CSL.Token, and then the CSL.Token into
the decorator function. I *think* that this only requires a small
modification to the Output functionality.
This would allow output formats to do fairly generic things while still
using a standard style; for example, for HTML, I could DIV tag journal
names (as well as entire bibliography references).
It shouldn't affect existing decorator functions as the additional
parameters will just get ignored.
Phil
Frank
This is excellent -- I shall test it out as soon as I can. This should
allow me to do everything that I need.
Many thanks!
Phil