...
At present when a question is bundled to an Ecml content all th,e ECML content all thee katex library dependencies like cssCSS,js, fonts etc are getting bundled even though the questions added to the stages does not contains contain any Formula(Equation) with it. But we need katex library only when a math text or formulas are presented on the question.So Katex library dependencies should be ignored on ecml ECML generation if no questions with formulae are present on any of the stages.
...
Part #2: Bundle/Remove Katex Plugins on Ecml Generation
When generating ecml ECML if questionbody contains the flag formula
with value true then we should include the katex library dependencies else those dependencies should be removed.
...
1. Remove katex dependencies from QuestionUnit Plugin Manifest and add on demand :
First, remove all katex library dependencies of questionunit plugin in its manifest. When StageManager invokes ecml ECML generation method of questionset plugin for each stage , while bundling each question check for the flag formula
in questionbody,If the value is true true then add the katex library dependencies and generate ecml. If the flag is not present or undefined then also add katex dependencies to support backward compatibility for older questions.
...
If we go by this approach then preview plugin requires changes as it will break while rendering question with formula if the katex library is not present.
...
When StageManager invokes the ecml ECML generation method of questionset plugin and none of the questions present on those stages has the formula
flag with value true in their body,then remove the katex library dependencies and generate ecml.
while removing the katex library dependencies keep a local buffer to hold those values and if any question with formula is added to stage further on the same session then the buffered dependencies should be added to questionunit plugin dependencies.
Among the above 2 approaches, the second one is the better one as it does not break the preview side.
...