<commit_before>/* eslint-disable max-lines */
import './Errors/StoneSyntaxError'
import './Errors/StoneCompilerError'

import './AST'
import './Support/contextualize'
import './Support/nextIndexOf'

const vm = require('vm')

export class StoneTemplate {
	compiler = null

	state = {
		file: null,
		contents: null,
		lines: null,
		index: 0
	}

	isLayout = false
	hasLayoutContext = false
	sections = [ ]

	expressions = [ ]
	spaceless = 0

	_template = null

	constructor(compiler, contents, file = null) {
		this.compiler = compiler
		this.state.contents = contents
		this.state.file = file

		const lines = contents.split(/\n/)
		const last = lines.length - 1
		let index = 0

		this.state.lines = lines.map((line, i) => {
			const length = line.length + (last === i ? 0 : 1)

			const range = {
				start: index,
				end: index + length,
				code: line,
				subsring: contents.substring(index, index + length)
			}

			index = range.end

			return range
		})
	}

	compile() {
		// Strip comments
		// TODO: This is going to break source maps
		let contents = this.state.contents.trim().replace(/\{\{--([\s\S]+)--\}\}/g, '')<commit_msg>Fixed issue with multiple comments/output braces [#19]<commit_after>/* eslint-disable max-lines */
import './Errors/StoneSyntaxError'
import './Errors/StoneCompilerError'

import './AST'
import './Support/contextualize'
import './Support/nextIndexOf'

const vm = require('vm')

export class StoneTemplate {
	compiler = null

	state = {
		file: null,
		contents: null,
		lines: null,
		index: 0
	}

	isLayout = false
	hasLayoutContext = false
	sections = [ ]

	expressions = [ ]
	spaceless = 0

	_template = null

	constructor(compiler, contents, file = null) {
		this.compiler = compiler
		this.state.contents = contents
		this.state.file = file

		const lines = contents.split(/\n/)
		const last = lines.length - 1
		let index = 0

		this.state.lines = lines.map((line, i) => {
			const length = line.length + (last === i ? 0 : 1)

			const range = {
				start: index,
				end: index + length,
				code: line,
				subsring: contents.substring(index, index + length)
			}

			index = range.end

			return range
		})
	}

	compile() {
		// Strip comments
		// TODO: This is going to break source maps
		let contents = this.state.contents.trim().replace(/\{\{--([\s\S]+?)--\}\}/g, '')
{'fraction_non_alphanumeric': 0.14698275862068966, 'fraction_numerical': 0.00603448275862069, 'mean_word_length': 2.960750853242321, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2214221', 'n_tokens_mistral': 864, 'n_tokens_neox': 746, 'n_words': 208}