Biblio...eStyle(3pm)

πŸ“¦
version 0.06 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

Biblio::EndnoteStyle β€” formatting your references with Endnote-style templates, bestie πŸ’–

(also, hi, this is a 3pm page β€” that's the User Contributed Perl Documentation section, so you already know it's a perl module thing ✨)


✨ SYNOPSIS ✨

use Biblio::EndnoteStyle;
$style = new Biblio::EndnoteStyle();
($text, $errmsg) = $style->format($template, \%fields);

that's literally it. three lines. we love a low-effort icon 🫢


πŸ’– DESCRIPTION πŸ’–

okay so this lil module is your girl for formatting bibliographic references, and it does it using style templates that are basically the same vibe as the ones in the super popular reference manager Endnote (<http://www.endnote.com/>). no cap.

the API is embarrassingly simple (the manpage's words, and honestly? correct 😭): you make a formatter object with the class's constructor, the new() method, and then you can call format() on that object over and over again, with the same template or different ones. she's flexible like that πŸ’…

(and like β€” the only reason the object exists at all is to cache compiled templates so that calling format() multiple times is faster than it would be otherwise. that's the whole job. apart from that, the API could have just been one single function. iconic of her to still be an object though πŸ‘‘)


πŸŽ€ METHODS πŸŽ€

new()

$style = new Biblio::EndnoteStyle();

makes you a brand-new formatter object ✨ takes no arguments, she doesn't need them, she's self-sufficient 🌸

debug()

$olddebug = $style->debug(1);

flips debugging on or off and hands you back the old debugging status πŸ¦‹

if you pass an argument, debugging gets turned on or off depending on whether that argument is true or false. either way, you get the old value of the debugging status back β€” so calling it with no argument is a completely side-effect-free inquiry. just asking, no consequences, we respect that πŸ’œ

when debugging is on, compiled templates get dumped to standard error.

fair warning bestie: it is not pretty. the manpage said it, not me. πŸ’€

format()

($text, $errmsg) = $style->format($template, \%fields);

this is the main character right here πŸ”₯ she formats a reference β€” which is just a hash of fields β€” according to an Endnote-like template.

the template is a string that's essentially the same as the ones used in Endnote, as documented in the Endnote X User Guide at <http://www.endnote.com/support/helpdocs/EndNoteXWinManual.pdf> pages 390ff. and heads up, pages 415-210 have the details of the recipe format. go read if you're that kinda girlie πŸ“š

and because the templates in this module are plain text, a few special characters are doing actual jobs:

  • Β¬ β€” links adjacent words together. this is the "non-breaking space" described on page 418 of the EndNote X πŸ’«
  • | β€” forced separation of elements that would otherwise be dependent.
  • ^ β€” separator for singular/plural alternatives.
  • ` β€” used to prevent literal text from being interpreted as a fieldname.

the hash of fields gets passed by reference: keys are fieldnames, and the values that go with them are the data πŸ’–

PLEASE NOTE AN IMPORTANT DIFFERENCE. (their caps, and they meant it 😭) keys that don't appear in the hash at all are not considered to be fields β€” so if they show up in the template, they get interpreted as literal text. but keys that do appear in the hash while their values are undefined or empty are considered to be fields with no value, and they'll be formatted as empty with all their dependent text omitted.

so like, for example:

$style->format(";Author: ", { Author => "Taylor" }) eq ":Taylor: "
$style->format(";Author: ", { Author => "" }) eq ";"
$style->format(";Author: ", { xAuthor => "" }) eq ";Author: "

see how the difference hits? yeah. that's the whole thing. 🌈

format() returns two values: the formatted reference and an error-message. the error message is defined if and only if the formatted reference is not. so if you got text, you got no error, and vice versa. periodt πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Mike Taylor, <mike@miketaylor.org.uk> πŸ’Œ


Copyright (C) 2007 by Mike Taylor.

this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. slay 🫢


okay and a lil sign-off for the girlies who read all the way down here: this page came from the User Contributed Perl Documentation (that's the 3pm manual bit πŸ’…), built with perl v5.36.0, dated 2022-10-22. that's the whole footer, we're just being cute about it πŸŽ€βœ¨πŸŒΈ

πŸ“¦ where this page comes from