1Biblio::EndnoteStyle(3)User Contributed Perl DocumentatioBniblio::EndnoteStyle(3)
2
3
4
6 Biblio::EndnoteStyle - reference formatting using Endnote-like
7 templates
8
10 use Biblio::EndnoteStyle;
11 $style = new Biblio::EndnoteStyle();
12 ($text, $errmsg) = $style->format($template, \%fields);
13
15 This small module provides a way of formatting bibliographic references
16 using style templates similar to those used by the popular reference
17 management software Endnote (http://www.endnote.com/). The API is
18 embarrassingly simple: a formatter object is made using the class's
19 constructor, the "new()" method; "format()" may then be repeatedly
20 called on this object, using the same or different templates.
21
22 (The sole purpose of the object is to cache compiled templates so that
23 multiple "format()" invocations are more efficient than they would
24 otherwise be. Apart from that, the API might just as well have been a
25 single function.)
26
28 new()
29 $style = new Biblio::EndnoteStyle();
30
31 Creates a new formatter object. Takes no arguments.
32
33 debug()
34 $olddebug = $style->debug(1);
35
36 Turns debugging on or off and returns the old debugging status. If an
37 argument is provided, then debugging is turned either on or off
38 according to whether then argument is true or false. In any case, the
39 old value of the debugging status is returned, so that a call with no
40 argument is a side-effect-free inquiry.
41
42 When debugging is turned on, compiled templates are dumped to standard
43 error. It is not pretty.
44
45 format()
46 ($text, $errmsg) = $style->format($template, \%fields);
47
48 Formats a reference, consisting of a hash of fields, according to an
49 Endnote-like template. The template is a string essentially the same
50 as those used in Endnote, as documented in the Endnote X User Guide at
51 http://www.endnote.com/support/helpdocs/EndNoteXWinManual.pdf pages
52 390ff. In particular, pages 415-210 have details of the recipe format.
53 Because the templates used in this module are plain text, a few special
54 characters are used:
55
56 ¬ Link adjacent words. This is the "non-breaking space" described on
57 page 418 of the EndNote X
58
59 | Forced Separation of elements that would otherwise be dependent.
60
61 ^ Separator for singular/plural aternatives.
62
63 ` Used to prevent literal text from being interpreted as a fieldname.
64
65 The hash of fields is passed by reference: keys are fieldnames, and the
66 corresponding values are the data. PLEASE NOTE AN IMPORTANT
67 DIFFERENCE. Keys that do not appear in the hash at all are not
68 considered to be fields, so that if they appear in the template, they
69 will be interpreted as literal text; keys that appear in the hash but
70 whose values are undefined or empty are considered to be fields with no
71 value, and will be formatted as empty with dependent text omitted. So
72 for example:
73
74 $style->format(";Author: ", { Author => "Taylor" }) eq ":Taylor: "
75 $style->format(";Author: ", { Author => "" }) eq ";"
76 $style->format(";Author: ", { xAuthor => "" }) eq ";Author: "
77
78 "format()" returns two values: the formatted reference and an error-
79 message. The error message is defined if and only if the formatted
80 reference is not.
81
83 Mike Taylor, <mike@miketaylor.org.uk>
84
86 Copyright (C) 2007 by Mike Taylor.
87
88 This library is free software; you can redistribute it and/or modify it
89 under the same terms as Perl itself, either Perl version 5.8.4 or, at
90 your option, any later version of Perl 5 you may have available.
91
92
93
94perl v5.32.0 2020-07-28 Biblio::EndnoteStyle(3)