fix regression in latex2html
This commit is contained in:
@@ -293,7 +293,7 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_BIBTEXBROWSER_USE_LATEX2HTML() {
|
function test_BIBTEXBROWSER_USE_LATEX2HTML() {
|
||||||
$bibtex = "@article{aKey,title={\`a Book},author={Martin Monperrus},publisher={Springer},year=2009,pages={42--4242},number=1}\n";
|
$bibtex = "@article{aKey,title={\`a Book},author={J\'e Lo},publisher={Springer},year=2009,pages={42--4242},number=1}\n";
|
||||||
|
|
||||||
bibtexbrowser_configure('BIBTEXBROWSER_USE_LATEX2HTML', true);
|
bibtexbrowser_configure('BIBTEXBROWSER_USE_LATEX2HTML', true);
|
||||||
$test_data = fopen('php://memory','x+');
|
$test_data = fopen('php://memory','x+');
|
||||||
@@ -303,6 +303,7 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
$db->update_internal("inline", $test_data);
|
$db->update_internal("inline", $test_data);
|
||||||
$dis = $db->getEntryByKey('aKey');
|
$dis = $db->getEntryByKey('aKey');
|
||||||
$this->assertEquals("à Book",$dis->getTitle());
|
$this->assertEquals("à Book",$dis->getTitle());
|
||||||
|
$this->assertEquals("Jé Lo",$dis->getFormattedAuthorsString());
|
||||||
|
|
||||||
bibtexbrowser_configure('BIBTEXBROWSER_USE_LATEX2HTML', false);
|
bibtexbrowser_configure('BIBTEXBROWSER_USE_LATEX2HTML', false);
|
||||||
$test_data = fopen('php://memory','x+');
|
$test_data = fopen('php://memory','x+');
|
||||||
@@ -312,6 +313,7 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
$db->update_internal("inline", $test_data);
|
$db->update_internal("inline", $test_data);
|
||||||
$dis = $db->getEntryByKey('aKey');
|
$dis = $db->getEntryByKey('aKey');
|
||||||
$this->assertEquals("\`a Book",$dis->getTitle());
|
$this->assertEquals("\`a Book",$dis->getTitle());
|
||||||
|
$this->assertEquals("J\'e Lo",$dis->getFormattedAuthorsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -1189,15 +1189,18 @@ class BibEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transformValue($value) {
|
function transformValue($value) {
|
||||||
// trim space
|
if (c('BIBTEXBROWSER_USE_LATEX2HTML'))
|
||||||
$value = xtrim($value);
|
{
|
||||||
|
// trim space
|
||||||
|
$value = xtrim($value);
|
||||||
|
|
||||||
// transform Latex markup to HTML entities (easier than a one to one mapping to each character)
|
// transform Latex markup to HTML entities (easier than a one to one mapping to each character)
|
||||||
// HTML entity is an intermediate format
|
// HTML entity is an intermediate format
|
||||||
$value = latex2html($value);
|
$value = latex2html($value);
|
||||||
|
|
||||||
// transform to the target output encoding
|
// transform to the target output encoding
|
||||||
$value = html_entity_decode($value, ENT_QUOTES|ENT_XHTML, OUTPUT_ENCODING);
|
$value = html_entity_decode($value, ENT_QUOTES|ENT_XHTML, OUTPUT_ENCODING);
|
||||||
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,11 +1213,8 @@ class BibEntry {
|
|||||||
// we assume that "comment" is never latex code
|
// we assume that "comment" is never latex code
|
||||||
// but instead could contain HTML code (with links using the character "~" for example)
|
// but instead could contain HTML code (with links using the character "~" for example)
|
||||||
// so "comment" is not transformed too
|
// so "comment" is not transformed too
|
||||||
if ($name!='url' && $name!='comment') {
|
if ($name!='url' && $name!='comment') {
|
||||||
|
|
||||||
if (c('BIBTEXBROWSER_USE_LATEX2HTML')) {
|
|
||||||
$value = $this->transformValue($value);
|
$value = $this->transformValue($value);
|
||||||
}
|
|
||||||
|
|
||||||
// 4. transform existing encoded character in the new format
|
// 4. transform existing encoded character in the new format
|
||||||
if (function_exists('mb_convert_encoding') && OUTPUT_ENCODING != BIBTEX_INPUT_ENCODING) {
|
if (function_exists('mb_convert_encoding') && OUTPUT_ENCODING != BIBTEX_INPUT_ENCODING) {
|
||||||
@@ -3804,7 +3804,7 @@ class BibDataBase {
|
|||||||
/** Adds a new bib entry to the database. */
|
/** Adds a new bib entry to the database. */
|
||||||
function addEntry($entry) {
|
function addEntry($entry) {
|
||||||
if (!$entry->hasField('key')) {
|
if (!$entry->hasField('key')) {
|
||||||
die('error: a bibliographic entry must have a key '.$entry->getText());
|
throw new Exception('error: a bibliographic entry must have a key '.$entry->getText());
|
||||||
}
|
}
|
||||||
// we keep its insertion order
|
// we keep its insertion order
|
||||||
$entry->order = count($this->bibdb);
|
$entry->order = count($this->bibdb);
|
||||||
|
|||||||
Reference in New Issue
Block a user