','<)/",' $1'); Markup(']+?)\s*\n\s?/",'$1 '); Markup('emquo','style',"/(<.*?>['\"]*(?:`')?\s?)|(.?['\"]+(?:`')?\s?)/", "squoHandler"); Markup('sq|','>inline',"/(\\[\\[[^|\\]]+\\|)(.*?)(\\]\\])/", "squolinkHandler"); Markup('sq->','>inline',"/(\\[\\[)([^\\]]+?)(-+>.*?\\]\\])/", "squolinkHandler"); SDV($SmartQuoteStyle, 'GB'); $SmartQuoteChars = array( 'CH' => array('o' => array('l' => 'la', 'r' => 'ra'), 'i' => array('l' =>'lsa', 'r' => 'rsa')), 'DE' => array('o' => array('l' => 'bd', 'r' => 'ld'), 'i' => array('l' =>'sb', 'r' => 'ls')), 'DK' => array('o' => array('l' => 'ra', 'r' => 'la'), 'i' => array('l' =>'rsa', 'r' => 'lsa')), 'ES' => array('o' => array('l' => 'la', 'r' => 'ra'), 'i' => array('l' =>'ld', 'r' => 'rd')), 'FI' => array('o' => array('l' => 'rd', 'r' => 'rd'), 'i' => array('l' =>'rs', 'r' => 'rs')), 'FR' => array('o' => array('l' => 'la', 'r' => 'ra'), 'i' => array('l' =>'ld', 'r' => 'rd')), 'GB' => array('o' => array('l' => 'ld', 'r' => 'rd'), 'i' => array('l' =>'ls', 'r' => 'rs')), 'NL' => array('o' => array('l' => 'bd', 'r' => 'rd'), 'i' => array('l' =>'sb', 'r' => 'rs')), 'PL' => array('o' => array('l' => 'bd', 'r' => 'rd'), 'i' => array('l' =>'la', 'r' => 'ra')), 'SE' => array('o' => array('l' => 'ra', 'r' => 'ra'), 'i' => array('l' =>'ls', 'r' => 'rs')), ); function emquoHandler($m) { return $m[1].ltrim(SmartenQuotes(' '.$m[2])).$m[3]; } function squoHandler($m) { return BypassHTML($m[1],$m[2]); } function squolinkHandler($m) { return $m[1].SmartenLinkText($m[2]).$m[3]; } function SmartenLinkText($txt) { global $LinkPattern,$UrlExcludeChars,$ImgExtPattern; if (!preg_match("/($LinkPattern)([^$UrlExcludeChars]+$ImgExtPattern)/",$txt)) $txt = preg_replace_callback("/(<.*?>['\"]*\s?)|(.?['\"]+\s?)/", function ($m) { return BypassHTML($m[1],$m[2]); }, $txt); return $txt; } function BypassHTML($hstring,$qstring) { if ($qstring=='') { $qstring = preg_replace("/.*>/",'',$hstring); $hstr = preg_replace("/>.*/",'>',$hstring); if (trim($qstring)=='') $r = $qstring; else { if (strstr($hstr,"")) $qstring = ">" . $qstring; $r = SmartenQuotes($qstring); } return $hstr.$r; } else return SmartenQuotes($qstring); } function SmartenQuotes($chars) { global $SmartQuoteStyle, $SmartQuoteChars; $s = 0; $r = ''; $sty = $SmartQuoteStyle; if ($chars[0] =="'" || $chars[0] == '"') { $quotes = $chars; $char = ''; } else { $quotes = substr($chars,1); $char = $chars[0]; if ($char=='`') $sty = 'GB'; elseif (strlen($quotes)>1 && $quotes[0]==$quotes[1] && !strstr(" =-[(",$char)) { $p = ($quotes[0]=="'") ? "p" : "P"; $r = "$char&$p" . "rime;"; $s = 2; $char = "`"; } } $hands = array('l','r'); $h = ($char=="" || strstr(" =-[(",$char)) ? 0 : 1; if ($char=="`" || $char==">") $char = ""; $r .= $char; $x = ''; if (preg_match("/\s$/",$quotes,$m)) { $quotes = rtrim($quotes); $x = ' '; } elseif ($h && $quotes=="'") $sty = 'GB'; $preq = 'x'; for ($i=$s;$i