From 73a4b893f7436b80b36abac41ef935827a0649e5 Mon Sep 17 00:00:00 2001 From: connorhaugh <49422820+connorhaugh@users.noreply.github.com> Date: Tue, 11 Apr 2023 09:23:02 -0400 Subject: [PATCH] Feat parse solution as sibling (#303) * fear: parse solution as siblings * feat: add error resliancy to solution check. --- src/editors/containers/ProblemEditor/data/OLXParser.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.js b/src/editors/containers/ProblemEditor/data/OLXParser.js index c0f21f40c..34fd9346c 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.js @@ -392,7 +392,12 @@ export class OLXParser { Object.entries(solution.div).forEach(([key, value]) => { if (key.indexOf('@_' === -1)) { // The redundant "explanation" title should be removed. - if ((key === 'p' || key === 'h2') && (value['#text'] === 'Explanation' || value[0]['#text'] === 'Explanation')) { + // If the key is a paragraph or h2, and the text of either the first or only item is "Explanation." + if ( + (key === 'p' || key === 'h2') + && (_.get(value, '#text', null) === 'Explanation' + || (_.isArray(value) && _.get(value[0], '#text', null) === 'Explanation')) + ) { if (_.isArray(value)) { value.shift(); parsedSolution[key] = value;