 
 WorkoutHeader.prototype.render = () ->
 	'<div class="workout-header">' +
-		this._text +
+		toHtml(this._text) +
 	'</div>'
 
 Exercises = (exercises) -> this

WorkoutsView = (workouts) ->
	html = []

	html.push workouts.renderMeta()

	workouts.getAll().forEach (workout) ->
		html.push workout.render()

	this._html = html.join('')
	this

WORKOUT_SEPARATOR = '\n\n'


toHtml = (text) ->
	text.replace(/\n/g, '<br>')

Workouts = (text) ->
	this._chunks = text.split(WORKOUT_SEPARATOR)
	this._sections = this._chunks.reduce((sections, section, idx) ->
		# TODO: add workout validator static method
		# TODO: abstract this logic out to allow for more types of content
		w = new Workout(section)
		if w.isValid()
			sections.push(w)
		else
			m = new MetaSection(section)
			sections.push(m)
		sections
	, [])
	this

Workouts.prototype.getAll = () ->
	this._sections.slice()

MetaSection = (sectionText) ->
	this._meta = sectionText
	this

MetaSection.prototype.render = () ->
	'<div class="meta-section">' +
		toHtml(this._meta) +
	'</div>'

Workout = (workoutText) ->
