\1\2\3\4

' . "\n"; // Catches transitions // Looks for a colon, with some hard coded exceptions that don't use colons. $pattern[] = '/\n([^<>\na-z]*?:|FADE TO BLACK\.|FADE OUT\.|CUT TO BLACK\.)[\s]??\n/'; $replace[] = '

\1

' . "\n"; // Catches multi-line action blocks // looks for all caps without punctuation, then two Newlines. // This differentiates from character cues because Cues will only have a single break, then the dialogue/parenthetical. $pattern[] = '/\n{2}(([^a-z\n\:]+?[\.\?\,\s\!]*?)\n{2}){1,2}/'; $replace[] = "\n" . '

\2

' . "\n"; // Catches character cues // Looks for all caps, parenthesis (for O.S./V.O.), then a single newline. $pattern[] = '/\n([^<>a-z\s][^a-z:\!\?]*?[^a-z\(\!\?:,][\s]??)\n{1}/'; // minor change that makes it work better $replace[] = '

\1

'; // Catches parentheticals // Just looks for text between parenthesis. $pattern[] = '/(\([^<>]*?\)[\s]??)\n/'; $replace[] = '

\1

'; // Catches dialogue // Must follow a character cue or parenthetical. $pattern[] = '/(

.*<\/p>|

.*<\/p>)\n{0,1}(.+?)\n/'; $replace[] = '\1' . "\n" . '

\2

' . "\n"; // Defaults. $pattern[] = '/([^<>]*?)\n/'; $replace[] = '

\1

' . "\n"; // Hack - cleans up the mess the action regex is leaving behind. $pattern[] = '/

[\n\s]*?<\/p>/'; $replace[] = ""; // Styling $pattern[] = '/(\*{2}|\[b\])(.*?)(\*{2}|\[\/b\])/'; $replace[] = '\2'; $pattern[] = '/(\*{1}|\[i\])(.*?)(\*{1}|\[\/i\])/'; $replace[] = '\2'; $pattern[] = '/(_|\[u\])(.*?)(_|\[\/u\])/'; $replace[] = '\2'; // Find all the scrippet blocks. // Only text between matched scrippet blocks will be processed by the text replacement. $scrippet_pattern = "/[\[<]scrippet[\]>](.*?)[\[<]\/scrippet[\]>]/si"; preg_match_all($scrippet_pattern, $text, $matches); $matches = $matches[1]; // we only need the matches of the (.*?) group $output = ''; // initialize $num_matches = count($matches); if($num_matches > 0) { for($i=0; $i < $num_matches; $i++) { // Remove any HTML tags in the scrippet block $matches[$i] = preg_replace('/<\/p>|/i', "\n", $matches[$i]); $matches[$i] = strip_tags($matches[$i]); $matches[$i] = $matches[$i] . "\n"; // this is a hack to eliminate some weirdness at the end of the scrippet // Regular Expression Magic! $output = $wrap_before . '

' . preg_replace($pattern, $replace, $matches[$i]) . '
' . $wrap_after; $text = preg_replace($scrippet_pattern, $output, $text, 1); } } return $text; } ?>