Set default <?php in the text area to restore syntax highlighting, fixes #10
This commit is contained in:
@@ -33,12 +33,12 @@ error_reporting(E_ALL | E_STRICT);
|
|||||||
$debugOutput = '';
|
$debugOutput = '';
|
||||||
|
|
||||||
if (isset($_POST['code'])) {
|
if (isset($_POST['code'])) {
|
||||||
$code = $_POST['code'];
|
|
||||||
|
|
||||||
if (get_magic_quotes_gpc()) {
|
if (get_magic_quotes_gpc()) {
|
||||||
$code = stripslashes($code);
|
$code = stripslashes($code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$code = trim(preg_replace('{^\s*<\?(php)?}i', '', $_POST['code']));
|
||||||
|
|
||||||
// if there's only one line wrap it into a krumo() call
|
// if there's only one line wrap it into a krumo() call
|
||||||
if (preg_match('#^(?!var_dump|echo|print|< )([^\r\n]+?);?\s*$#is', $code, $m) && trim($m[1])) {
|
if (preg_match('#^(?!var_dump|echo|print|< )([^\r\n]+?);?\s*$#is', $code, $m) && trim($m[1])) {
|
||||||
$code = 'krumo('.$m[1].');';
|
$code = 'krumo('.$m[1].');';
|
||||||
@@ -88,7 +88,7 @@ if (isset($_POST['code'])) {
|
|||||||
<div class="output"><?php echo $debugOutput ?></div>
|
<div class="output"><?php echo $debugOutput ?></div>
|
||||||
<form method="POST" action="">
|
<form method="POST" action="">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<textarea class="editor" id="editor" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : null) ?></textarea>
|
<textarea class="editor" id="editor" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : "<?php\n\n") ?></textarea>
|
||||||
<div class="statusbar">
|
<div class="statusbar">
|
||||||
<span class="position">Line: 1, Column: 1</span>
|
<span class="position">Line: 1, Column: 1</span>
|
||||||
<span class="copy">
|
<span class="copy">
|
||||||
|
|||||||
+2
-3
@@ -80,9 +80,8 @@
|
|||||||
var PhpMode, code;
|
var PhpMode, code;
|
||||||
|
|
||||||
code = $('#' + options.editor).text();
|
code = $('#' + options.editor).text();
|
||||||
$('#' + options.editor)
|
$('#' + options.editor).replaceWith('<div id="'+options.editor+'" class="'+options.editor+'"></div>');
|
||||||
.replaceWith('<div id="'+options.editor+'" class="'+options.editor+'"></div>')
|
$('#' + options.editor).text(code);
|
||||||
.text(code);
|
|
||||||
|
|
||||||
editor = ace.edit(options.editor);
|
editor = ace.edit(options.editor);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user