#!/usr/bin/env ruby theText = STDIN.readlines dialogueBlock = 0 sceneheaders = "INT EXT EST" transitions = "CUT FADE" def makeLine(line,element) # wrap element as paragraph puts '

' + line + '

' end puts '
' for line in theText do line.chomp! if line == "" then next end if line[0].chr == "(" then # check for parenthical makeLine(line,'parenthetical') dialogueBlock = 1 next end if dialogueBlock == 1 then # line must be dialogue makeLine(line,'dialogue') dialogueBlock = 0 next end if line == line.upcase then # must be character, header or transition if sceneheaders[line[0..2]] then # check for INT or EXT or EST makeLine(line,'sceneheader') elsif transitions[line[0..2]] then # check for CUT or FADE makeLine(line,'transition') else # must be character makeLine(line,'character') dialogueBlock = 1 end else # default to action makeLine(line,'action') end end puts '
'