fix bug in author separation
This commit is contained in:
@@ -456,7 +456,7 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals("Meyer, Heribert and Foo Bar", $entry->getFormattedAuthorsString());
|
$this->assertEquals("Meyer, Heribert and Foo Bar", $entry->getFormattedAuthorsString());
|
||||||
|
|
||||||
// Github issue 61
|
// Github issue 61
|
||||||
$bibtex = "@article{aKey61,title={An article Book},author = {Meyer, Heribert and {Advanced Air and Ground Research Team} and Foo Bar and J{\'e} Ko}}\n";
|
$bibtex = "@article{aKey61,title={An article Book},author = {Meyer, Heribert and {Advanced Air and Ground Research Team} and Foo Bar and J{\'e} Ko and J{\'e} Le and Fd L{\'e}}}\n";
|
||||||
// wrong parsing of author names
|
// wrong parsing of author names
|
||||||
$test_data = fopen('php://memory','x+');
|
$test_data = fopen('php://memory','x+');
|
||||||
fwrite($test_data, $bibtex);
|
fwrite($test_data, $bibtex);
|
||||||
@@ -465,12 +465,13 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
$db->update_internal("inline", $test_data);
|
$db->update_internal("inline", $test_data);
|
||||||
$entry = $db->getEntryByKey('aKey61');
|
$entry = $db->getEntryByKey('aKey61');
|
||||||
$authors = $entry->getRawAuthors();
|
$authors = $entry->getRawAuthors();
|
||||||
$this->assertEquals(4, count($authors));
|
$this->assertEquals(6, count($authors));
|
||||||
$this->assertEquals("Meyer, Heribert", $authors[0]);
|
$this->assertEquals("Meyer, Heribert", $authors[0]);
|
||||||
$this->assertEquals("Advanced Air and Ground Research Team", $authors[1]);
|
$this->assertEquals("Advanced Air and Ground Research Team", $authors[1]);
|
||||||
$this->assertEquals("Foo Bar", $authors[2]);
|
$this->assertEquals("Foo Bar", $authors[2]);
|
||||||
$this->assertEquals("J{\'e} Ko", $authors[3]);
|
$this->assertEquals("J{\'e} Ko", $authors[3]);
|
||||||
$this->assertEquals("Jé Ko", $entry->getFormattedAuthorsArray()[3]);
|
$this->assertEquals("J{\'e} Le", $authors[4]);
|
||||||
|
$this->assertEquals("Fd L{\'e}", $authors[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_latex2html() {
|
function test_latex2html() {
|
||||||
|
|||||||
+9
-8
@@ -976,7 +976,7 @@ function char2html_case_sensitive($line,$latexmodifier,$char,$entitiyfragment) {
|
|||||||
/** converts latex chars to HTML entities.
|
/** converts latex chars to HTML entities.
|
||||||
(I still look for a comprehensive translation table from late chars to html, better than [[http://isdc.unige.ch/Newsletter/help.html]])
|
(I still look for a comprehensive translation table from late chars to html, better than [[http://isdc.unige.ch/Newsletter/help.html]])
|
||||||
*/
|
*/
|
||||||
function latex2html($line) {
|
function latex2html($line, $do_clean_extra_bracket=true) {
|
||||||
|
|
||||||
$line = preg_replace('/([^\\\\])~/','\\1 ', $line);
|
$line = preg_replace('/([^\\\\])~/','\\1 ', $line);
|
||||||
|
|
||||||
@@ -1070,11 +1070,12 @@ function latex2html($line) {
|
|||||||
$line = str_replace('\\k{a}','ą',$line);
|
$line = str_replace('\\k{a}','ą',$line);
|
||||||
$line = str_replace('\\\'{c}','ć',$line);
|
$line = str_replace('\\\'{c}','ć',$line);
|
||||||
|
|
||||||
|
if ($do_clean_extra_bracket) {
|
||||||
// clean extra tex curly brackets, usually used for preserving capitals
|
// clean extra tex curly brackets, usually used for preserving capitals
|
||||||
// must come before the final math replacement
|
// must come before the final math replacement
|
||||||
$line = str_replace('}','',$line);
|
$line = str_replace('}','',$line);
|
||||||
$line = str_replace('{','',$line);
|
$line = str_replace('{','',$line);
|
||||||
|
}
|
||||||
|
|
||||||
// we restore the math env
|
// we restore the math env
|
||||||
for($i = 0; $i < count($maths); $i++) {
|
for($i = 0; $i < count($maths); $i++) {
|
||||||
@@ -1430,14 +1431,14 @@ class BibEntry {
|
|||||||
$res = array();
|
$res = array();
|
||||||
// we merge the remaining ones
|
// we merge the remaining ones
|
||||||
for ($i=0; $i < count($array)-1; $i++) {
|
for ($i=0; $i < count($array)-1; $i++) {
|
||||||
if (strpos( $array[$i], '{') !== FALSE && strpos($array[$i+1],'}') !== FALSE) {
|
if (strpos( latex2html($array[$i],false), '{') !== FALSE && strpos(latex2html($array[$i+1],false),'}') !== FALSE) {
|
||||||
$res[] = $this->clean_top_curly(trim($array[$i])." and ".trim($array[$i+1]));
|
$res[] = $this->clean_top_curly(trim($array[$i])." and ".trim($array[$i+1]));
|
||||||
$i = $i + 1;
|
$i = $i + 1;
|
||||||
} else {
|
} else {
|
||||||
$res[] = trim($array[$i]);
|
$res[] = trim($array[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!preg_match('/^\}/',$array[count($array)-1])) {
|
if (!preg_match('/\}/',latex2html($array[count($array)-1],false))) {
|
||||||
$res[] = trim($array[count($array)-1]);
|
$res[] = trim($array[count($array)-1]);
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
|
|||||||
Reference in New Issue
Block a user