Skip to content

Commit 38143ac

Browse files
committed
Line breaks are now preserved
1 parent 0d01edd commit 38143ac

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

frontend/src/App.css

+4
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@
4141

4242
}
4343

44+
.output-formmating{
45+
white-space: pre-wrap;
46+
47+
}

frontend/src/App.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ import RunCode from './run.png'
1212
import ResetCode from './reset.png'
1313
import InputBox from './InputBox';
1414

15+
16+
function NewlineText(props) {
17+
const text = props.text;
18+
return <div className='output-formmating'>{text}</div>;
19+
}
20+
21+
1522
function App() {
1623
const [ text, setText ] = useState('') //State to store editor code
1724
const [output, setOutput] = useState('')//State to store output
1825
const [isLoading, setIsLoading] = useState(false);//Loading animations
1926
const [ input, setInput ] = useState('')
2027

28+
2129
const handleInputChange = (e) => {
2230
e.preventDefault(); // prevent the default action
2331
setInput(e.target.value); // set name to e.target.value (event)
@@ -78,12 +86,14 @@ function App() {
7886
<Card.Body>
7987

8088
<Card.Text>
89+
{/* Spinning Animation While Request is processed */}
8190
{isLoading ? <p className='loading'><Spinner animation="border" size="sm" /></p> : null}
82-
{output}
91+
<NewlineText text={output} />
8392
</Card.Text>
8493

8594
</Card.Body>
8695
</Card>
96+
{/* Input Box to provide input for program */}
8797
<InputBox value={input} onChange={handleInputChange}/>
8898
</div>
8999

0 commit comments

Comments
 (0)