From 6b080f0de96ae774a65daa66b4dd4a47a6f98c8c Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Sun, 10 Oct 2010 10:51:22 +0200 Subject: [PATCH] last changes to get @string and crossref 100% right --- bibtexbrowser.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/bibtexbrowser.php b/bibtexbrowser.php index aeb606c..da7a7f7 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -655,8 +655,9 @@ class BibDBBuilder { foreach ($entryvalue_array as $k=>$v) { // spaces are allowed when using #, they are not taken into account // however # is not istself replaced by a space + // warning: @strings are not case sensitive // see http://newton.ex.ac.uk/tex/pack/bibtex/btxdoc/node3.html - $stringKey=trim($v); + $stringKey=strtolower(trim($v)); if (isset($this->stringdb[$stringKey])) { // this field will be formated later by xtrim and latex2html @@ -665,17 +666,11 @@ class BibDBBuilder { // we keep a trace of this replacement // so as to produce correct bibtex snippets $this->currentEntry->constants[$stringKey]=$this->stringdb[$stringKey]; - } else { - // we simply trim the entry - $entryvalue_array[$k]=trim($v); // trimmed value } } $entryvalue=implode('',$entryvalue_array); - if ($finalkey!='url') $formatedvalue = latex2html(xtrim($entryvalue)); - else $formatedvalue = trim($entryvalue); - - $this->currentEntry->setField($finalkey,$formatedvalue); + $this->currentEntry->setField($finalkey,$entryvalue); } function setEntryType($entrytype) { @@ -765,6 +760,7 @@ function latex2html($line) { $line = char2html($line,"'",'o',"acute"); $line = char2html($line,"'",'u',"acute"); $line = char2html($line,"'",'y',"acute"); + $line = char2html($line,"'",'n',"acute"); $line = char2html($line,'`','a',"grave"); $line = char2html($line,'`','e',"grave"); @@ -849,10 +845,9 @@ class BibEntry { /** Sets a field of this bib entry. */ function setField($name, $value) { - // only @string keeps the cases - if ($this->getType()!='string') { - $name = strtolower($name); - } + $name = strtolower($name); + $value = xtrim($value); + if ($name!='url') $value = latex2html($value); $this->fields[$name] = $value; }