From e6b318f9613318d106aa3e369747a2cdbff3d86d Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 1 Feb 2018 04:54:40 -0500 Subject: [PATCH 1/3] add composer script for builtin server (#83) --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 84301f5..e6af602 100644 --- a/composer.json +++ b/composer.json @@ -12,5 +12,8 @@ ], "require": { "php": ">=4" + }, + "scripts": { + "serve": ["@php -S localhost:29896 bibtexbrowser.php"] } } From f0392d3cf046fca0eb66580eb11cc57169aca34a Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 2 Feb 2018 03:36:14 -0500 Subject: [PATCH 2/3] Improve doc to reflect new composer script (#84) --- bibtexbrowser-documentation.wiki | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bibtexbrowser-documentation.wiki b/bibtexbrowser-documentation.wiki index cffce94..f22480a 100755 --- a/bibtexbrowser-documentation.wiki +++ b/bibtexbrowser-documentation.wiki @@ -553,6 +553,15 @@ In your project's `composer.json`, just add this
"monperrus/bibtexbrowser":
 }
 
+With composer, a test server can be started with this command: +
composer serve
+Which runs this script: +
php -S localhost:29896 bibtexbrowser.php
+ +Now, to display a particular bibtex file in your browser, the URI should be of this form: +
localhost:29896/?bib=bibfile.bib
+Note the forward slash following the port number. + ====How to add a banner to the main view in frameset mode?==== For instance, if you want to add a "home page" button in the main view of the frameset mode, add a banner function in ''bibtexbrowser.local.php'' as follows: From a4b1c9e00f80ad1229b46ae093ed97731ff633f2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Feb 2018 04:28:34 -0500 Subject: [PATCH 3/3] Refactor string handling functions --- bibtexbrowser.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 613de6d..e891e64 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -74,7 +74,7 @@ if (defined('ENCODING')) { // 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'); +@define('MATHJAX_URI', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/config/TeX-AMS_HTML.js?V=2.7.1'); // the default jquery URI @define('JQUERY_URI', '//code.jquery.com/jquery-1.5.1.min.js'); @@ -959,10 +959,8 @@ function xtrim($line) { // 2010-06-30 // bug found by Thomas // windows new line is **\r\n"** and not the other way around!! - $line = str_replace("\r\n",' ', $line);//windows like - $line = str_replace("\n",' ', $line);//unix-like - // we also replace tabs - $line = str_replace("\t",' ', $line); + // according to php.net: Proncess \r\n's first so they aren't converted twice + $line = str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $line); // remove superfluous spaces e.g. John+++Bar $line = preg_replace('/ {2,}/',' ', $line); return $line; @@ -988,11 +986,9 @@ function latex2html($line, $do_clean_extra_bracket=true) { $line = preg_replace('/([^\\\\])~/','\\1 ', $line); - $line = str_replace('---','—',$line); - $line = str_replace('--','–',$line); + $line = str_replace(array('---', '--'), array('—', '–'), $line); - $line = str_replace('``','"', $line); - $line = str_replace("''",'"', $line); + $line = str_replace(array('``', "''"), array('"', '"'), $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) @@ -1228,7 +1224,7 @@ class BibEntry { // we assume that "comment" is never latex code // but instead could contain HTML code (with links using the character "~" for example) // so "comment" is not transformed too - if ($name!='url' && $name!='comment' + if ($name!='url' && $name!='comment' && !preg_match('/^hp_/',$name) // homepage links should not be transformed with latex2html ) { $value = $this->transformValue($value); @@ -4152,7 +4148,7 @@ echo "\n".' -->'; ?> -