diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index 186e569..1a248f9 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -473,6 +473,8 @@ class BTBTest extends PHPUnit_Framework_TestCase { } function test_latex2html() { + $this->assertEquals('"', latex2html("``")); + $this->assertEquals('"', latex2html("''")); $this->assertEquals('é', latex2html("\'e")); $this->assertEquals('é', latex2html("{\'e}")); } diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 2d10595..e4837c0 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -983,6 +983,9 @@ function latex2html($line) { $line = str_replace('---','—',$line); $line = str_replace('--','–',$line); + $line = str_replace('``','"', $line); + $line = str_replace("''",'"', $line); + // performance increases with this test // bug found by Serge Barral: what happens if we have curly braces only (typically to ensure case in Latex) // added && strpos($line,'{')===false @@ -1016,6 +1019,7 @@ function latex2html($line) { // " the letters "i" and "j" require special treatment when they are given accents because it is often desirable to replace the dot with the accent. For this purpose, the commands \i and \j can be used to produce dotless letters." $line = preg_replace('/\\\\([ij])/i','\\1', $line); + $line = char2html($line,"'",'a',"acute"); $line = char2html($line,"'",'e',"acute"); $line = char2html($line,"'",'i',"acute"); @@ -1066,6 +1070,7 @@ function latex2html($line) { $line = str_replace('\\k{a}','ą',$line); $line = str_replace('\\\'{c}','ć',$line); + // clean extra tex curly brackets, usually used for preserving capitals // must come before the final math replacement $line = str_replace('}','',$line);