@@ -5,6 +5,21 @@ import Icon from "components/common/icon";
5
5
import Markdown from "components/common/markdown" ;
6
6
import style from "./style.scss" ;
7
7
8
+ function parseQuestionText ( text ) {
9
+ if ( ! text ) return { introduction : "" , numberWithLabel : "" , text : "" } ;
10
+
11
+ try {
12
+ const [ introduction , ...content ] = text . split ( "\n\n\n" ) ;
13
+ const [ numberWithLabel , ...remainingText ] = content . join ( "\n\n\n" ) . split ( ":" ) ;
14
+ const questionText = remainingText . join ( ":" ) . trim ( ) ;
15
+
16
+ return { introduction, numberWithLabel, text : questionText } ;
17
+ } catch ( error ) {
18
+ console . error ( "Error parsing question text:" , { text, error} ) ;
19
+ return { introduction : "" , numberWithLabel : "" , text : "" } ;
20
+ }
21
+ }
22
+
8
23
function Question ( { question} ) {
9
24
const [ showContent , setShowContent ] = useState ( false ) ;
10
25
const parsedText = parseQuestionText ( question . text ) ;
@@ -41,21 +56,6 @@ function Question({question}) {
41
56
) ;
42
57
}
43
58
44
- function parseQuestionText ( text ) {
45
- if ( ! text ) return { introduction : "" , numberWithLabel : "" , text : "" } ;
46
-
47
- try {
48
- const [ introduction , ...content ] = text . split ( "\n\n\n" ) ;
49
- const [ numberWithLabel , ...remainingText ] = content . join ( "\n\n\n" ) . split ( ":" ) ;
50
- const questionText = remainingText . join ( ":" ) . trim ( ) ;
51
-
52
- return { introduction, numberWithLabel, text : questionText } ;
53
- } catch ( error ) {
54
- console . error ( "Error parsing question text:" , { text, error } ) ;
55
- return { introduction : "" , numberWithLabel : "" , text : "" } ;
56
- }
57
- }
58
-
59
59
Question . propTypes = {
60
60
question : PropTypes . shape ( {
61
61
adaptability : PropTypes . string ,
0 commit comments