 	class Boundary
 		length: () ->
 			return @end - @start
+
+		extract: (str) ->
+			return str.substr @start, @length()
 
 	# Returns the outer and inner boundaries of the latex block starting
 	# at the given opening delimiter

			# the rendered latex content
			rendered = @render_latex parts.latex, match.options.displayMode
			result += parts.before + rendered
			
			# Set what comes after the latex block to be examined next
			str = parts.after


			rendered =  "<div class=\"katex-error katex-#{display_mode}-error\">"
			rendered += 	"#{e.message}"
			rendered += "</div>"

		return rendered

	# Takes a string and renders all latex blocks inside it
	render: (str) ->
		result = ''

		loop

			# Find the first latex block in the string
			match = @find_latex str

			unless match?
				result += str
				break
