Skip to content

Commit

Permalink
style: add a comment explaining why we parse and build question separ…
Browse files Browse the repository at this point in the history
…ately
  • Loading branch information
Cup0fCoffee committed Jan 31, 2023
1 parent 76553aa commit f6d7042
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/editors/containers/ProblemEditor/data/OLXParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ export class OLXParser {
return _.map(questionObject, (obj) => _.mapKeys(obj, (value, key) => _.get(tagMap, key, key)));
};

// To be able to generate question's HTML, such that it respects the initial
// order of elements and styles stored in the OLX, we parse and build
// original `olxString` with `preserveOrder: true`. We parse and build the
// question separately, because the JSON structure produced with
// `preserveOrder: true` option is more complex and hard to work with, and
// since the order of nested elements is not important in other places, we
// restrict the complexity of the produced JSON within the scope of this
// method.
const parser = new XMLParser({
preserveOrder: true,
trimValues: false,
Expand Down

0 comments on commit f6d7042

Please sign in to comment.