@@ -178,6 +178,37 @@ const OpenEHRQuest: React.FC = () => {
178
178
179
179
const currentLevel = levels [ gameState . currentLevel ] ;
180
180
181
+ const renderChallenge = ( challenge : string , language : string ) => {
182
+ const parts = challenge . split ( / ( \n \n ) / ) ;
183
+ let inCodeBlock = false ;
184
+
185
+ return parts . map ( ( part , index ) => {
186
+ if ( part === '\n\n' ) {
187
+ return < br key = { `br-${ index } ` } /> ;
188
+ }
189
+
190
+ if ( part . trim ( ) . startsWith ( '<' ) || part . trim ( ) . startsWith ( '{' ) ) {
191
+ inCodeBlock = true ;
192
+ }
193
+
194
+ if ( inCodeBlock ) {
195
+ return (
196
+ < CodeHighlight
197
+ key = { `code-${ index } ` }
198
+ code = { part . trim ( ) }
199
+ language = { language }
200
+ />
201
+ ) ;
202
+ }
203
+
204
+ return (
205
+ < p key = { `text-${ index } ` } className = "mb-2" >
206
+ { part }
207
+ </ p >
208
+ ) ;
209
+ } ) ;
210
+ } ;
211
+
181
212
return (
182
213
< div className = "flex flex-col items-center justify-center min-h-screen bg-gray-100 p-4" >
183
214
< Card className = "w-full max-w-4xl" >
@@ -206,16 +237,9 @@ const OpenEHRQuest: React.FC = () => {
206
237
</ Alert >
207
238
< div className = "my-4" >
208
239
< h2 className = "text-xl font-semibold mb-2" > Challenge:</ h2 >
209
- { currentLevel . language !== 'text' ? (
210
- < CodeHighlight
211
- code = { currentLevel . challenge }
212
- language = { currentLevel . language }
213
- />
214
- ) : (
215
- < pre className = "bg-gray-800 text-white p-4 rounded-md overflow-x-auto whitespace-pre-wrap break-words" >
216
- < code > { currentLevel . challenge } </ code >
217
- </ pre >
218
- ) } { ' ' }
240
+ < div className = "bg-gray-800 text-white p-4 rounded-md overflow-x-auto whitespace-pre-wrap break-words" >
241
+ { renderChallenge ( currentLevel . challenge , currentLevel . language ) }
242
+ </ div > { ' ' }
219
243
</ div >
220
244
< div className = "space-y-2" >
221
245
{ currentLevel . options . map ( ( option , index ) => (
0 commit comments