Skip to content

Instantly share code, notes, and snippets.

@anna-bucher
Created June 17, 2009 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anna-bucher/131486 to your computer and use it in GitHub Desktop.
Save anna-bucher/131486 to your computer and use it in GitHub Desktop.
/* Copyright: http://textile.thresholdstate.com/ */
function span($text)
{
$qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~','\^');
$pnct = ".,\"'?!;:";
foreach($qtags as $f) {
$text = preg_replace_callback("/
(?:^|(?<=[\s>$pnct])|([{[]))
($f)(?!$f)
({$this->c})
(?::(\S+))?
([^\s$f]+|\S[^$f\n]*[^\s$f\n])
([$pnct]*)
$f
(?:$|([\]}])|(?=[[:punct:]]{1,2}|\s))
/x", array(&$this, "fSpan"), $text);
}
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment