author-only option in processor for citation
mapreal19 opened this issue · 5 comments
I was trying to generate a citation with only the author. As described in this feature:
But this might not work anymore? I pulled the code and run that feature in local and have this failure:
Is there anything that might have broken this? And why cucumber tests are not running in Travis?
suppress-author
in the other hand is working fine
Anything I could help with? I might include here rubocop & gemfile.lock too
I'm sorry, I think you did everything right, but If I remember correctly, author-only
has not been implemented yet.
ah got it! I could help implementing, any guidance on where I should make the changes?
I think we'd have to mark the fact that we want to render the author only around here by adding suppressing all other valid roles. Something like item.suppress! 'editor', 'translator', ...
-- every valid name variable should probably be suppressed.
Then we have to render the citation but instead walk through the style starting at the citation node (I think author-only
is not really standardized, so I'm making this up) and, instead of rendering each node as currently happens, render only Names
nodes: because we added all the roles to be suppressed, we should then be able to discard every node that does not render anything and keep only those that do (presumably those are the authors). Then join those results somehow (how?) or just keep the first one (sane styles will render the author only once anyway).
So the main question is how to walk the style, rendering only names nodes, elegantly. I think what we could do is add an optional flag to the citation items with a kind of node filter: i.e., the generic render method checks if the current node is filtered or not around here, and if it is, it passes along a flag to the specialized render method that it should not render anything 'by itself' -- just handing down the citation item to the next nodes. When a node (e.g., a names node) is hit, it should remove the filter from the item temporarily, render its own contents, and then restore the filter again.
@inukshuk thanks for the very detailed explanation. I'll try to tackle this when having a bit of time. For now as a quick patch in the client/calling code I'm removing the last item after last comma in the citation. e.g. (Author & Author2, 2000)
Yeah, technically I think that's fine: the suppress/only author options are actually not part of the CSL spec I believe, but citeproc-js behavior. There's been lot's of discussion recently how to properly support something like BibTeX's natbib
in CSL and it's possible that a combination of these two will be used (i.e., to render the citation two times) so they may become part of CSL. But for now, I think it's also perfectly fine to create your own customized styles for this (I think that's actually the only other viable solution to support this in CSL: to create additional top-level layout nodes like 'author-only' etc. and let the style authors define each variant).