A question about document types and document.get_field()
Christopher Belanger <chris.belanger <at> utoronto.ca>
2011-12-19 23:03:08 GMT
First off, I love Referencer, so thanks for all the hard work. As a
humanities student, I often find myself needing to compile
bibliographies. Obviously LaTeX is awesome for this, but if someone
wants me to e-mail them a list of references, it doesn't make sense to
make a new .tex file and generate a pdf.
So I've been working on a plugin to export plaintext citations from
Referencer to the clipboard. It's pretty simple, but if I finish it
I'll gladly share it.
However, I'm having problems with document.get_field(). In order to get
the bibliographic information, the plugin needs to get a bunch of
fields. The problem is that if it tries to get a field that doesn't
exist, rather than just returning a null value for that field, it throws
an exception and the plugin doesn't return anything at all.
I've gone through the source code, and this seems to happen on or around
line 774 of Document.c.
So, first question: is this a bug? If so, it seems like it would be
easy to just change that line from 'throw std::etc....' to 'return "";',
which would allow the plugin to keep chugging along with an empty variable.
Second question: documents have different "genres" or "types," such as
article, book, etc., and I know this determines which fields are
defined. However I can't find a direct way for a plugin to find out
what type a document is. Is there such a function I just can't find?
If so, that would allow me to make sure I only get the fields defined