diff --git a/QuestionPaperPreview.js b/QuestionPaperPreview.js index 49049af..5088d15 100644 --- a/QuestionPaperPreview.js +++ b/QuestionPaperPreview.js @@ -39,6 +39,7 @@ function QuestionPaperPreview(jsonData){ function convertToLatex(text, mathstatus) { + // console.log(text); // Parse mathstatus into a boolean const mathStatusBoolean = JSON.parse(mathstatus); // Check if the text contains
tags @@ -130,21 +131,48 @@ function QuestionPaperPreview(jsonData){ var currentSno_length =currentSno.length-(currentSno.length/2) if (currentSno_length == 1) { - description_align =17 + description_align =27 } else if (currentSno_length == 2) { description_align =33 }else if(currentSno_length == 3){ description_align =48 }else if(currentSno_length == 4) { - description_align =64 + description_align =62 } else if(currentSno_length == 5) { description_align =78 } + + var GroupQuestionTilteAlign = 0; if (question.group_title) { + // console.log(question); + let cleanedTex = question.question_id.replace(/\s+/g, ' ').trim(); + let cleanedText=cleanedTex.replace('
','').replace('
','') + var question_id_length =cleanedText.length; + if (question_id_length == 1) { + GroupQuestionTilteAlign =15 + } else if (question_id_length == 3) { + GroupQuestionTilteAlign =33 + }else if(question_id_length == 5){ + GroupQuestionTilteAlign =47 + }else if(question_id_length == 7) { + GroupQuestionTilteAlign =63 + }else if(question_id_length == 4) { + GroupQuestionTilteAlign =40 + }else if(question_id_length == 6) { + GroupQuestionTilteAlign =54 + } + + + + // const questionId =`${cleanedText})
` + + const questionId =cleanedText + console.log(questionId); + const questionGroupSetP = `${question.group_title}`; - const questionGroupmodify =questionGroupSetP.replaceAll('', `
`) + const questionGroupmodify =questionGroupSetP.replaceAll('
', `
`) if (question.group_attempt_any) { var questionGroupAttempt = `
Attempt Any : ${question.group_attempt_any}
` @@ -169,7 +197,7 @@ function QuestionPaperPreview(jsonData){ // questionGroupMark = questionGroupMark.replace('', '
') // } - questionPaper += `
','').replace('
','') + + var question_id_length =cleanedText.length; + console.log(question_id_length); + if (question_id_length == 1) { + GroupQuestionTilteAlign =14 + } else if (question_id_length == 3) { + GroupQuestionTilteAlign =26 + }else if(question_id_length == 5){ + GroupQuestionTilteAlign =41 + }else if(question_id_length == 7) { + GroupQuestionTilteAlign =54 + }else if(question_id_length == 2) { + GroupQuestionTilteAlign =25 + }else if(question_id_length == 4) { + GroupQuestionTilteAlign =42 + }else if(question_id_length == 6) { + GroupQuestionTilteAlign =58 + } + // console.log(question); + // const questionId =`${cleanedText})
`; + const questionI =cleanedText; + var questionId = questionI.replace('', '
'); + console.log(questionId); + const questionTex = question.question; - const questionText = questionTex.replaceAll('
', `
`); + const questionText = questionTex.replaceAll('
', `
`); // console.log(questionText); const questionDescriptio = question.question_description; const questionDescription = questionDescriptio.replaceAll('
', '
') @@ -198,8 +252,11 @@ function QuestionPaperPreview(jsonData){ - questionPaper += `
tags + console.log(text); + // console.log("ff") + if (!/
|<\/p>/i.test(text)) { + // console.log('text:' , text) + if (mathStatusBoolean) { + // console.log('text1:' , text) + // Use MathJax to convert the text to LaTeX + const cov = MathJax.tex2chtml(text).outerHTML; + console.log('cov:' , cov) + + return cov; + } else { + // Return the text as-is + + return text; + } + } else { + console.log("pq") + const cov = MathJax.tex2chtml(text).outerHTML; + console.log('cov:' , cov) + + return cov; + // Return the text as-is + return text; + } +} \ No newline at end of file diff --git a/QuestionPreview.html b/QuestionPreview.html index 6b0ddea..3e3b302 100644 --- a/QuestionPreview.html +++ b/QuestionPreview.html @@ -49,8 +49,13 @@ + +