diff --git a/bibtexbrowser.php b/bibtexbrowser.php
index 4914678..bfc3ea7 100755
--- a/bibtexbrowser.php
+++ b/bibtexbrowser.php
@@ -56,6 +56,11 @@ function bibtexbrowser_configure($key, $value) {
@define('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');// this is the name of a function
@define('BIBLIOGRAPHYSECTIONS','DefaultBibliographySections');// this is the name of a function
@define('BIBLIOGRAPHYTITLE','DefaultBibliographyTitle');// this is the name of a function
+
+// shall we load MathJax to render math in $…$ in HTML?
+@define('BIBTEXBROWSER_RENDER_MATH', true);
+@define('MATHJAX_URI', '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML.js');
+
// can we load bibtex files on external servers?
@define('BIBTEXBROWSER_LOCAL_BIB_ONLY', true);
@@ -879,6 +884,13 @@ function char2html_case_sensitive($line,$latexmodifier,$char,$entitiyfragment) {
*/
function latex2html($line) {
+ $line = preg_replace('/([^\\\\])~/','\\1 ', $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
+ if (strpos($line,'\\')===false && strpos($line,'{')===false) return $line;
+
$maths = array();
$index = 0;
// first we escape the math env
@@ -889,13 +901,6 @@ function latex2html($line) {
$index++;
}
- $line = preg_replace('/([^\\\\])~/','\\1 ', $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
- if (strpos($line,'\\')===false && strpos($line,'{')===false) return $line;
-
// we should better replace this before the others
// in order not to mix with the HTML entities coming after (just in case)
$line = str_replace('\\&','&', $line);
@@ -1699,7 +1704,7 @@ function get_HTML_tag_for_layout() {
*/
function bib2links_default(&$bibentry) {
$links = array();
-
+
if (BIBTEXBROWSER_BIBTEX_LINKS) {
$link = $bibentry->getBibLink();
if ($link != '') { $links[] = $link; };
@@ -1719,7 +1724,7 @@ function bib2links_default(&$bibentry) {
$link = $bibentry->getGSLink();
if ($link != '') { $links[] = $link; };
}
-
+
return '';
}
@@ -1963,7 +1968,7 @@ return
.bibbooktitle { font-style:italic; }
.bibauthor { }
.bibpublisher { }
-
+
See http://schema.org/ScholarlyArticle for the metadata
*/
function DefaultBibliographyStyle(&$bibentry) {
@@ -2199,7 +2204,7 @@ function createQueryString($array_param) {
if($key == Q_INNER_KEYS_INDEX) {continue;}
$array_param[$key]=$key .'='. urlencode($val);
}
-
+
// adding the bibtex file name is not already there
if (isset($_GET[Q_FILE]) && !isset($array_param[Q_FILE])) {
// first we add the name of the bib file
@@ -2319,6 +2324,19 @@ $('a.biburl').each(function() { // for each url "[bibtex]"
} // end function javascript
+if (!function_exists('javascript_math')) {
+ function javascript_math() {
+ ?>
+
+
+ searchView().'
';
@@ -2701,7 +2719,7 @@ class SimpleDisplay {
return array(array('robots','noindex'));
}
}
-
+
/** sets the entries to be shown */
function setEntries(&$entries) {
$this->entries = $entries;
@@ -2730,8 +2748,8 @@ class SimpleDisplay {
function setQuery($query) {
$this->query = $query;
}
- function getTitle() {
- return _DefaultBibliographyTitle($this->query);
+ function getTitle() {
+ return _DefaultBibliographyTitle($this->query);
}
/** Displays a set of bibtex entries in an HTML table */
@@ -2894,7 +2912,7 @@ class AcademicDisplay {
$display->incHeadingLevel();
$display->setEntries($entries);
$display->headerCSS = 'theader';
-
+
$sections[] = array (
'display' => $display,
'anchor' => $anchor,
@@ -3385,7 +3403,7 @@ class BibDataBase {
$result[$key] = $year;
}
-
+
krsort($result);
return $result;
}
@@ -3704,6 +3722,10 @@ if (method_exists($content, 'getTitle')) {
if (BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT) {
javascript();
}
+
+ if (BIBTEXBROWSER_RENDER_MATH) {
+ javascript_math();
+ }
?>