Report abuse

	function scrippetize(text) { 
	var scrippet_pattern_string = '[\\[<]scrippet[\\]>]([^]*?)[\\[<]\\/scrippet[\\]>]';
	var scrippet_pattern = new RegExp(scrippet_pattern_string, "i");	
	var scrippet_pattern_g = new RegExp(scrippet_pattern_string, "gi");
	
	while (matches = scrippet_pattern_g.exec(text)) {
		var output = '
' + "\r\n" + matches[1].replace(/<[^>]*>/g, '') /* remove any tags Wordpress or Markdown may dump into the scrippet */ .replace(/\r/g, '') /* some basic character replacements to deal with bugs that Wordpress/Markdown introduce */ .replace(/&/g, '&') .replace(/\.{3}|É/g, '...') .replace(/\-{2}|Ñ|?/g, '--') .replace(/(INT|EXT|EST)([\.\-\s]+?)(.+?)([A-Za-z0-9\)\s\.])\n/g, '

$1$2$3$4

' + "\r\n") /* Sceneheaders must start with INT or EXT */ .replace(/\n([^<>\na-z]*?:|FADE TO BLACK\.|FADE OUT\.|CUT TO BLACK\.)[\s]??\n/g, '

$1

' + "\r\n") /* Catches transitions -- Looks for a colon, with some hard coded exceptions that don't use colons. */ .replace(/\n([^<>\n]*?:[^\n]+?)\n/g, '

$1

' + "\r\n") .replace(/\n{2}(([^a-z\n\:]+?[\.\?\,\s\!]*?)\n{2}){1,2}/g, "\n" + '

$2

' + "\r\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. */ .replace(/\n([^<>a-z\s][^a-z:\!\?]*?[^a-z\(\.\!\?:,][\s]??)\n/g, '

$1

') /* Catches character cues -- Looks for all caps, parenthesis (for O.S./V.O.), then a single newline. */ .replace(/(\([^<>]*?\)[\s]??)\n/g, '

$1

') /* Catches parentheticals -- Just looks for text between parenthesis. */ .replace(/(

.*<\/p>|

.*<\/p>)\n{0,1}(.+?)\n/g, '$1

$2

' + "\r\n") /* Catches dialogue -- Must follow a character cue or parenthetical. */ .replace(/([^<>]*?)\n/g, '

$1

' + "\r\n") /* Defaults */ .replace(/

[\n\s]*?<\/p>/g, '') /* Hack - cleans up the mess the action regex is leaving behind.*/ .replace(/\n/g, '') /* hide newlines from live comments */ + '\r\n

'; text = text.replace(scrippet_pattern, output); } return text; }