<commit_before><?php

	// Turn on Error Reporting
	ini_set('display_errors', 1);
	error_reporting(E_ALL);
	
	// Helper function
	function pr($arg){ echo "<pre>"; print_r($arg); echo "</pre>"; }

	// Show me output that's it
	if(isset($_GET['p'])){
		if(file_exists('code.txt') && is_writable('code.txt')){	include 'code.txt';	}
		else{	$path = pathinfo(__FILE__);
				echo "Create a writable file <b>code.txt</b> in '{$path['dirname']}' directory.";
			}

		exit;
	}

	// Init URI and Base Path
	$uri = isset($_SERVER['PATH_INFO']) ? explode('/',$_SERVER['PATH_INFO']) : array();
	preg_match('/(.+)index.php/',$_SERVER['PHP_SELF'], $match );
	$base = $match[1];

	// Just Reset the page
	if(isset($_GET['r'])){
		file_put_contents('code.txt', '');
		header('Location: '. $base);
		exit();
	}

	// Useful vars 
	$code = ''; // will contain final code

	function slug($title){ return preg_replace("/[^a-zA-Z0-9]+/", "-", strtolower($title)); }
	// Get if available in post
	if(isset($_POST['code'])){
		$code = $_POST['code'];
	}

	// Put if yes get if no! we want code!
	if($code){
		$reg = '/<style s[ac]ss>?([\S\s]+)<\/style>/';
		$sass_path = 'scss/SassParser.php';
		preg_match_all($reg, $code, $mc);
		if( isset($mc[1][0]) && file_exists($sass_path) ) // Handle Sass Compilation
		{
			require_once $sass_path;
			file_put_contents('tmp.scss', $mc[1][0]);
			$sass = new SassParser(array('style'=>'compressed'));
			$scss = $sass->toCSS('tmp.scss');
			$code = preg_replace($reg, "<style>\n\t" . $scss . "\n  </style>" , $code);
		}
		file_put_contents('code.txt',$code) ;
	}
	// if($code){ file_put_contents('code.txt', $code); }
	else{ $code = file_get_contents('code.txt'); }

?><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Programming Editors</title>
	<style type="text/css">
		body{overflow:hidden;margin:0}
		header{background-color: #4d4d4d; background-image:-webkit-linear-gradient(top,#03416a48%,#25547b74%,#03416a42%);height:50px;-moz-box-shadow:0 0 5px #333;-webkit-box-shadow:0 0 5px #333;-o-box-shadow:0 0 5px #333;box-shadow:0 0 5px #333}
		header #logo{font-size:2em;font-weight:700;color:#FFF;font-style:italic;font-family:Halvatica;margin-left:20px}
		#main{position:absolute;height:94%;width:100%; min-height: 300px;}
		#editor,#processed{display:block;}
		#processed{ height: 60%; }

		#code,#editor form{height:100%}
		.controls{position:absolute;right:50px}
		#code{width:100%;font-family:consolas,monaco,'courier new', serif;font-size:15px;
		outline:none;padding-top:5px;border:5px solid #550505;-webkit-box-sizing:border-box;
		height: 300px;
		box-shadow:0 0 4px #201F1F;resize:none;background:#eee;color:#5E0303; tab-size: 3;}
		#editor{background-color:#eee}
		#processed iframe{width:100%;height:100%;border:10px solid #eee;-webkit-box-sizing:border-box}
		input[type=submit]{margin:4px}
		#update{ display: none; }
		#gists{ position: absolute; right: 20px; top: 20px; display: none; }

		a.home{ color: white; float: right; font-size: .5em; margin: 5px; }
	</style>
	<link rel="stylesheet" href="<?php echo $base; ?>codemirror/codemirror.css">
	</head>
<body>	
	<header>
		<div id="logo">editor
		<a href="https://github.com/vinnizworld/code_editor" target="_blank" class="home">Help</a>
		</div>
		
	</header>	
	<div id="main">
		<div id="editor">
			<form action="" method="post">
				<div id="code"><?php echo htmlentities($code); ?></div><commit_msg>Fixed ace editor font issue, where cursor was being positioned wrongly.<commit_after><?php

	// Turn on Error Reporting
	ini_set('display_errors', 1);
	error_reporting(E_ALL);
	
	// Helper function
	function pr($arg){ echo "<pre>"; print_r($arg); echo "</pre>"; }

	// Show me output that's it
	if(isset($_GET['p'])){
		if(file_exists('code.txt') && is_writable('code.txt')){	include 'code.txt';	}
		else{	$path = pathinfo(__FILE__);
				echo "Create a writable file <b>code.txt</b> in '{$path['dirname']}' directory.";
			}

		exit;
	}

	// Init URI and Base Path
	$uri = isset($_SERVER['PATH_INFO']) ? explode('/',$_SERVER['PATH_INFO']) : array();
	preg_match('/(.+)index.php/',$_SERVER['PHP_SELF'], $match );
	$base = $match[1];

	// Just Reset the page
	if(isset($_GET['r'])){
		file_put_contents('code.txt', '');
		header('Location: '. $base);
		exit();
	}

	// Useful vars 
	$code = ''; // will contain final code

	function slug($title){ return preg_replace("/[^a-zA-Z0-9]+/", "-", strtolower($title)); }
	// Get if available in post
	if(isset($_POST['code'])){
		$code = $_POST['code'];
	}

	// Put if yes get if no! we want code!
	if($code){
		$reg = '/<style s[ac]ss>?([\S\s]+)<\/style>/';
		$sass_path = 'scss/SassParser.php';
		preg_match_all($reg, $code, $mc);
		if( isset($mc[1][0]) && file_exists($sass_path) ) // Handle Sass Compilation
		{
			require_once $sass_path;
			file_put_contents('tmp.scss', $mc[1][0]);
			$sass = new SassParser(array('style'=>'compressed'));
			$scss = $sass->toCSS('tmp.scss');
			$code = preg_replace($reg, "<style>\n\t" . $scss . "\n  </style>" , $code);
		}
		file_put_contents('code.txt',$code) ;
	}
	// if($code){ file_put_contents('code.txt', $code); }
	else{ $code = file_get_contents('code.txt'); }

?><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Programming Editors</title>
	<style type="text/css">
		body{overflow:hidden;margin:0}
		header{background-color: #4d4d4d; background-image:-webkit-linear-gradient(top,#03416a48%,#25547b74%,#03416a42%);height:50px;-moz-box-shadow:0 0 5px #333;-webkit-box-shadow:0 0 5px #333;-o-box-shadow:0 0 5px #333;box-shadow:0 0 5px #333}
		header #logo{font-size:2em;font-weight:700;color:#FFF;font-style:italic;font-family:Halvatica;margin-left:20px}
		#main{position:absolute;height:94%;width:100%; min-height: 300px;}
		#editor,#processed{display:block;}
		#processed{ height: 60%; }

		#code,#editor form{height:100%}
		.controls{position:absolute;right:50px}
		#code{width:100%;font-family:consolas,monaco,'courier new', serif;font-size:15px;
		outline:none;padding-top:5px;border:5px solid #550505;-webkit-box-sizing:border-box;
		height: 300px;
		box-shadow:0 0 4px #201F1F;resize:none;background:#eee;color:#5E0303; tab-size: 3;}
		#editor{background-color:#eee}
		#processed iframe{width:100%;height:100%;border:10px solid #eee;-webkit-box-sizing:border-box}
		input[type=submit]{margin:4px}
		#update{ display: none; }
		#gists{ position: absolute; right: 20px; top: 20px; display: none; }

		a.home{ color: white; float: right; font-size: .5em; margin: 5px; }

		.ace_editor div { font-family: monospace; }
	</style>
	</head>
<body>	
	<header>
		<div id="logo">editor
		<a href="https://github.com/vinnizworld/code_editor" target="_blank" class="home">Help</a>
		</div>
		
	</header>	
	<div id="main">
		<div id="editor">
			<form action="" method="post">
				<div id="code"><?php echo htmlentities($code); ?></div>
{'fraction_non_alphanumeric': 0.21412900394910048, 'fraction_numerical': 0.036565745209887375, 'mean_word_length': 5.008787346221441, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 71, 'https://': 2, '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': '7333496', 'n_tokens_mistral': 2961, 'n_tokens_neox': 2635, 'n_words': 483}