 
 	hasDocumentEnvironment = (text) ->
 		re = /^\\begin{document}/m
+		envs = []
+		iterations = 0
+		return re.exec(text) != null
+
+	hasBibliographyEnvironment = (text) ->
+		re = /^\\begin{thebibliography}/m
 		envs = []
 		iterations = 0
 		return re.exec(text) != null

			\\end{frame}
		"""
		meta: "env"
	}, {
		caption: "\\begin{thebibliography}..."
		snippet: """
			\\begin{thebibliography}{$1}

					staticSnippets.splice(ind, 1)
			else
				staticSnippets.push documentSnippet

			if hasBibliographyEnvironment(docText)
				ind = staticSnippets.indexOf(bibliographySnippet)
				if ind != -1
					staticSnippets.splice(ind, 1)
			else
				staticSnippets.push bibliographySnippet

			parsedItemsMap = {}
			for environment in customEnvironments
