I have the following laravel form and I want to copy the text from the code editor as it were wrote:
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 150px;
right: 150px;
bottom: 150px;
left: 150px;
}
.ace_editor {
border: 1px solid lightgray;
margin: auto;
height: 65%;
width: 55%;
}
.scrollmargin {
height: 80px;
text-align: center;
}
</style>
{!! Form::open(['action' => 'ProblemsController@store']) !!}
<div id="editor"></div>
<input type="textarea" name="codeSrc" id="codeSrc" style="display: none;">
{{Form::submit('Submit')}}
{!! Form::close() !!}
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/chrome");
editor.session.setMode("ace/mode/c_cpp");
//here I am taking the text from the hidden textarea
editor.session.on('change', function(delta) {
var content=document.getElementById('hiddenInput');
content.value=editor.getValue();
});
</script>
I want to take the text input as it is, like that:
// Your First C++ Program
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
}
Not in a single line like that, the \n is just ignored // Your First C++ Program#include int main() {std::cout << "Hello World!";return 0;}
Even the <iostream>
got disappeared because it is interpreted as an html tag. The point of this is to transfer it to an .cpp file and execute it, so I want it as it is, not modified.