Browse Source

adds support for new latex characters

pull/63/merge
Martin Monperrus 9 years ago
parent
commit
d026780fed
  1. 2
      bibtexbrowser-test.php
  2. 5
      bibtexbrowser.php

2
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}"));
}

5
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}','&#261',$line);
$line = str_replace('\\\'{c}','&#263',$line);
// clean extra tex curly brackets, usually used for preserving capitals
// must come before the final math replacement
$line = str_replace('}','',$line);

Loading…
Cancel
Save