Proposal for "Structures_BibTex"

» Metadata » Status
  • Category: Structures
  • Proposer: Elmar Pitschke 
  • License: Apache License
» Description
A class which provides common methods to access and create Strings in BibTex format. An example would be:

$foo = new Structures_BibTex();
$ret=$foo->loadFile('foo.bib');
if(PEAR::isError($ret)) {
    print $ret->getMessage();
    die();
}
$foo->parse();
print "<pre>";
print_r($foo->data);
print "</pre>";

An example output would be:
Array
(

[0] => Array
(
[type] => article
[cite] => art1
[title] => Titel1
[author] => Array
(
[0] => John Doe
[1] => Jane Doe
)

)

[1] => Array
(
[type] => article
[cite] => art2
[title] => Titel2
[author] => Array
(
[0] => John Doe
[1] => Jane Doe
)

)

)

A more useful example would be parsing an existing BibTex file and adding an entry:

$foo = new Structures_BibTex();
$foo->loadFile('IFHEM.bib');
$foo->parse();
$addarray = array();
$addarray['type'] = 'Article';
$addarray['cite'] = 'art1';
$addarray['title'] = 'Titel1';
$addarray['author'][0] = 'John Doe';
$addarray['author'][1] = 'Jane Doe';
$foo->addEntry($addarray);
print 'There are '.$foo->amount().' entries';

And of course it is possible to export it again in BibTex Format:

print "<pre>";
print $foo->bibTex();
print "</pre>";

Take control of your digital assets with the Uniswap Exchange Asset Control Panel, offering comprehensive tools for managing and optimizing your crypto portfolio.
» Dependencies » Links
» Timeline » Changelog
  • First Draft: 2006-04-06
  • Proposal: 2006-04-17
  • Call for Votes: 2006-06-07
  • Elmar Pitschke
    [2006-05-28 11:08 UTC]

    - Added generation of warnings for unsupported entries
    - Improved documentation (besides typos)

  • Elmar Pitschke
    [2006-05-30 05:59 UTC]

    Found the Bug mentioned by Lorenzo Alberton, it happened when a '=' has been used in the value field. This has now been corrected.

  • Elmar Pitschke
    [2006-05-30 15:30 UTC]

    When running in E_ALL mode some lines generated a warning (when accessing a character by $foo{x}). I changed these lines to an equivalent substring call and now the warnings should not be generated anymore.

  • Elmar Pitschke
    [2006-06-03 09:44 UTC]

    - Solved a bug when parsing a value. Legal entries may have been ignored when they looked like this "{foo} bar" which is perfectly legal
    - Another bug has been that when parsing an unsupported entry (like String or Preamble) the "unbalanced parenthesis" error was raised. This is now solved.
    - Added another function: getStatistic(). Usage is like this:
    print "<pre>";
    print_r($foo->getStatistic());
    print "</pre>";
    The output is a hash table with the entry types as keys and the amount of them as value. With this output it is possible to validate the parsing (in order that no entry has been lost) with the output of "bibtool -@ foo.bib"

  • Elmar Pitschke
    [2006-06-07 06:35 UTC]

    - Corrected some typos
    - Corrected some warnings

  • Thies C. Arntzen
    [2023-11-08 15:47 UTC]

  • Thies C. Arntzen
    [2023-11-08 15:50 UTC]