All pastes #2075544 Raw Edit

Stuff

public text v1 · immutable
#2075544 ·published 2011-06-06 12:55 UTC
rendered paste body
function WakabaMark($string){

    $patterns = array(
    '`\\\\\\\\`',
    '`\\\\\*`',
    '`\\\\_`',
    '`\\\\\:`',
    '`\\\\\^`',
    '`\\\\\#`',
    '`\\\\\%`',
    '`\*\*(.+?)\*\*`is', 
    '`\*(.+?)\*`is',
    '`\:\:(.+?)\:\:`is', 
    '`\^\^(.+?)\^\^`is', 
    '`\#\#(.+?)\#\#`is', 
    '`\%\%(.+?)\%\%`is', 
    '`\_\_(.+?)\_\_`is', 
    '`\_(.+?)\_`is', 
);

$replaces =  array(
    '\',
    '*',
    '_',
    ':',
    '^',
    '#',
    '%',
    "<b>\\1</b>", 
    "<span style=\"border-bottom: 1px solid\">\\1</span>", 
    "<i>\\1</i>", 
    "<strike>\\1</strike>",
    "<span style='font-family: \"Segoe Script Typeface\";'>\\1</span>", 
    "<span class='spoiler' onmouseover='this.style.color=\"green\";' onmouseout='this.style.color=\"gray\"'>\\1</span>",
    "<b>\\1</b>", 
    "<i>\\1</i>"
);

  $link_app = stripos($string, "://");
  $space_app = 0;

  if ($link_app != false) {

  $space_app = strpos(substr($string, $link_app, strlen($string)), " ");
  
  if ($space_app != false) {
    $space_app = $link_app + $space_app;
  } else {
    $space_app = strlen($string);
  }
  }

  $before = substr($string, 0, $link_app);
  $middle = substr($string, $link_app, $space_app-$link_app);
  $after = substr($string, $space_app);

  $before = preg_replace($patterns, $replaces , $before);
  $after = preg_replace($patterns, $replaces , $after);

  $string = $before.$middle.$after;

$string = preg_replace_callback('`\@\@(.+?)\@\@`is', array(&$this, 'code_callback'), $string);

return $string;

}