fix: process code input to handle newlines and tabs correctly; update CSS for better text wrapping
This commit is contained in:
@@ -457,13 +457,18 @@ const CodeChallenge = () => {
|
|||||||
try {
|
try {
|
||||||
// Submit code to the backend
|
// Submit code to the backend
|
||||||
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080';
|
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080';
|
||||||
|
|
||||||
|
// Ensure code has actual newlines, not escaped \n strings
|
||||||
|
// This handles cases where code might have literal "\n" instead of newlines
|
||||||
|
const processedCode = code.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
|
||||||
|
|
||||||
const response = await fetch(`${apiUrl}/api/submit`, {
|
const response = await fetch(`${apiUrl}/api/submit`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
code: code,
|
code: processedCode,
|
||||||
language: getLanguageIdentifier(language),
|
language: getLanguageIdentifier(language),
|
||||||
input: '',
|
input: '',
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1673,6 +1673,8 @@ body {
|
|||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
color: #212529;
|
color: #212529;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.console-line.system {
|
.console-line.system {
|
||||||
|
|||||||
Reference in New Issue
Block a user