From 1d3b1c74e1a823705dae8b7bdd6f50706e0badb9 Mon Sep 17 00:00:00 2001 From: ishikabhoyar Date: Sat, 8 Nov 2025 18:44:55 +0530 Subject: [PATCH] fix: process code input to handle newlines and tabs correctly; update CSS for better text wrapping --- Frontend/src/components/CodeChallenge.jsx | 7 ++++++- Frontend/src/index.css | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Frontend/src/components/CodeChallenge.jsx b/Frontend/src/components/CodeChallenge.jsx index 801af45..b4bf573 100644 --- a/Frontend/src/components/CodeChallenge.jsx +++ b/Frontend/src/components/CodeChallenge.jsx @@ -457,13 +457,18 @@ const CodeChallenge = () => { try { // Submit code to the backend 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`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ - code: code, + code: processedCode, language: getLanguageIdentifier(language), input: '', }), diff --git a/Frontend/src/index.css b/Frontend/src/index.css index 0b8e918..ef125c8 100644 --- a/Frontend/src/index.css +++ b/Frontend/src/index.css @@ -1673,6 +1673,8 @@ body { margin-bottom: 6px; line-height: 1.5; color: #212529; + white-space: pre-wrap; + word-wrap: break-word; } .console-line.system {