Browse Source

Merge branch 'lpirl-pr_math'

pull/30/merge
Martin Monperrus 10 years ago
parent
commit
c657db434d
  1. 36
      bibtexbrowser.php

36
bibtexbrowser.php

@ -56,6 +56,11 @@ function bibtexbrowser_configure($key, $value) {
@define('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');// this is the name of a function @define('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');// this is the name of a function
@define('BIBLIOGRAPHYSECTIONS','DefaultBibliographySections');// 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 @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? // can we load bibtex files on external servers?
@define('BIBTEXBROWSER_LOCAL_BIB_ONLY', true); @define('BIBTEXBROWSER_LOCAL_BIB_ONLY', true);
@ -879,6 +884,13 @@ function char2html_case_sensitive($line,$latexmodifier,$char,$entitiyfragment) {
*/ */
function latex2html($line) { 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(); $maths = array();
$index = 0; $index = 0;
// first we escape the math env // first we escape the math env
@ -889,13 +901,6 @@ function latex2html($line) {
$index++; $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 // we should better replace this before the others
// in order not to mix with the HTML entities coming after (just in case) // in order not to mix with the HTML entities coming after (just in case)
$line = str_replace('\\&','&', $line); $line = str_replace('\\&','&', $line);
@ -2318,6 +2323,19 @@ $('a.biburl').each(function() { // for each url "[bibtex]"
} // end function javascript } // end function javascript
if (!function_exists('javascript_math')) {
function javascript_math() {
?>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [["$","$"]]}
});
</script>
<script src="<?php echo MATHJAX_URI ?>"></script>
<?php
}
}
/** is used for creating menus (by type, by year, by author, etc.). /** is used for creating menus (by type, by year, by author, etc.).
usage: usage:
@ -3703,6 +3721,10 @@ if (method_exists($content, 'getTitle')) {
if (BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT) { if (BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT) {
javascript(); javascript();
} }
if (BIBTEXBROWSER_RENDER_MATH) {
javascript_math();
}
?> ?>
</body> </body>
</html> </html>

Loading…
Cancel
Save