From 7f91a835f90756ff1a1227349166f32396c55f59 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 5 Feb 2018 14:11:47 -0500 Subject: [PATCH] simplify string replace --- bibtexbrowser.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 8084cbb..aa50444 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -959,6 +959,7 @@ function xtrim($line) { // 2010-06-30 // bug found by Thomas // windows new line is **\r\n"** and not the other way around!! + // 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); @@ -985,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)