1Released through http://bibliophile.sourceforge.net under the GPL licence. 2Do whatever you like with this -- some credit to the author(s) would be appreciated. 3 4A collection of PHP classes to manipulate bibtex files. 5 6If you make improvements, please consider contacting the administrators at bibliophile.sourceforge.net so that your improvements can be added to the release package. 7 8Mark Grimshaw & Guillaume Gardey 2004 9http://bibliophile.sourceforge.net 10 11################################################ 12PARSEENTRIES 13############ 14This reads the contents of a BibTeX .bib file or a PHP string and returns arrays of information representing @preamble, @string and valid BibTeX entries. 15 16Entries may be enclosed by {...} or (...). Fields values may be enclosed by "...", {...} or without enclosure. 17 18FLAGS can be set: 19$parse->fieldExtract; 20$parse->removeDelimit; 21$parse->expandMacro = FALSE/TRUE to expand macros within BibTeX entries ('#' and @string values). 22 23If $parse->fieldExtract == TRUE (default), the $entries array using the supplied example bib.bib file will be: 24Array 25( 26 [0] => Array 27 ( 28 [bibtexEntryType] => article 29 [bibtexCitation] => klitzing:qhe 30 [author] => K. v. Klitzing and G. Dorda = "and M. Pepper 31 [title] => New method for h{\i}gh mark@sirfragalot.com accuracy determination of fine structure constant based on quantized hall resistance 32 [journal] => PRL 33 [volume] => 45 34 [pages] => 494 35 [blah] => bl"ah 36 [year] => 1980 37 ) 38 39 [1] => Array 40 ( 41 [bibtexEntryType] => article 42 [bibtexCitation] => klitzing:nobel 43 [author] => Klaus von Klitzing 44 [title] => The Quantized Hall Effect 45 [journal] => RMP 46 [volume] => 58 47 [pages] => 519 48 [year] => 1986 49 ) 50) 51 52In other words, an array of separate BibTeX entries each one an array comprising the fields, entry type and given citation. @strings will be similarly formatted. 53 54If $parse->fieldExtract == FALSE, the $entries array using the supplied example bib.bib file will be: 55Array 56( 57 [0] => @ARTICLE{klitzing:qhe, AUTHOR="K. v. Klitzing and G. Dorda = "and M. Pepper", TITLE="New method for h{\i}gh mark@sirfragalot.com accuracy determination of fine structure constant based on quantized hall resistance", JOURNAL=PRL, VOLUME= 45, PAGES=494, blah=" bl"ah ", YEAR=1980 }, 58 [1] => @ARTICLE(klitzing:nobel, AUTHOR={Klaus von Klitzing}, TITLE="The Quantized Hall Effect",JOURNAL=RMP, VOLUME=58, PAGES=519, YEAR=1986 ) 59) 60 61In other words, an array of separate BibTeX entries with no further processing. @strings will be similarly formatted. 62NB - IF fieldExtract == FALSE, SETTINGS FOR expandMacro AND removeDelimit WILL HAVE NO EFFECT. 63 64If $parse->removeDelimit == TRUE (default), all double-quotes or braces that enclose field values of BibTeX entries/strings will be removed. Otherwise, they will be left in place. Setting this to TRUE only has an effect if $parse->fieldExtract is TRUE. 65 66In all cases, @preamble (from the given example bib.bib file) will be returned as: 67Array 68( 69 [bibtexPreamble] => Blah blah blah some preamble or other r 70) 71 72Additional BibTeX macro can be supplied to the parser: 73$more_macro = array("RMP" => "Rev., Mod. Phys.", "LNCS" => "Lecture Notes in Computer Science"); 74$parse->loadStringMacro($more_macro); 75 76$parse->returnArrays() will then return $entries with all BibTeX macros (BibTeX file + $more_macro) expanded. 77 78 79################################################ 80PARSECREATORS 81############# 82This takes a BibTeX author or editor field and splits it into the component writers returning a multidimensional array consisting of writer arrays comprised of array(firstname(s), initials, surname). It attempts to recognise 'et. al' or 'et. al.' and returns either FALSE or TRUE if that exists. If the input is 'Anon', 'anon', 'Anonymous' or 'anonymous' FALSE is returned. 83################################################ 84 85 86################################################ 87PARSEMONTH 88############# 89Split a bibtex month field into day and month components including date ranges. 90 list($startMonth, $startDay, $endMonth, $endDay) = $parseMonth->init($monthField); 91 92################################################ 93PARSEPAGE 94############# 95Split a bibtex pages field into page start and page end components. 96 list($start, $end) = $parsePage->init($pagesField);