QTI prompts, choices and chips keep the space between inline elements
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
The QTI viewer joins two words when the only thing between their inline elements is a space: a prompt containing Which <strong>planet</strong> <em>orbits</em> closest to the Sun? reads "Which planetorbits closest to the Sun?". SafeHTML drops the space before the QTI components see it, and the components could not lay it out correctly if they did. Prompts, choices and match or associate chips should keep the space and read as authored.
Complexity: Medium Target branch: develop
Context
SafeHTMLdrops every text node that holds only whitespace (SafeHTML/index.js#L286).- PR #16010 (#15598) keeps that space in plain HTML, but leaves the children of a registered component such as
qti-promptas they are. Prompt.vuewraps all its children in a<p>when one of them is text (Prompt.vue#L8-L15), so a kept space would nest an authored<p>inside another<p>.- Match and associate chips lay their children out as flex items, where a space between two elements has no width.
- The same drop gives "Mercury(first)" for a
qti-simple-choicecontaining<strong>Mercury</strong> <em>(first)</em>, and "Domesticcat" for a match or associate choice containing<strong>Domestic</strong> <em>cat</em>.
The Change
SafeHTMLshould keep whitespace-only text nodes for the children of registered components too, building on PR #16010.Prompt.vueshould wrap only runs of inline content in a<p>, leaving block children unwrapped.- Match and associate chips should lay out their content in an inline container, so a space between two elements keeps its width.
How to Get There
- Run the dev server and open
/en/learn/#/qti_sandbox/. - In "QTI XML editor", paste a choice item whose
qti-promptcontainsWhich <strong>planet</strong> <em>orbits</em> closest to the Sun?and whoseqti-simple-choiceelements contain<strong>Mercury</strong> <em>(first)</em>and<strong>Venus</strong> <em>(second)</em>. - Read the prompt and the choices under "Preview".
Acceptance Criteria
- [ ] A
qti-promptwhose only children are<strong>a</strong> <em>b</em>reads "a b", and gains no paragraph margin or width limit that it does not have ondevelop. - [ ] A
qti-promptwith<strong>a</strong> <em>b</em><p>Details</p>keeps the space, and the authored<p>is not inside another<p>. - [ ] A
qti-promptwith<strong>Use the figure</strong> <img src="/figure.png" alt="diagram"/>renders no<div>inside a<p>. - [ ] A
qti-simple-choice, and a match or associate choice in the response pool, a filled slot and a match source row, each read "a b" for<strong>a</strong> <em>b</em>. - [ ] A match or associate choice with
Figure <img src="/figure.png" alt="figure"/>keeps its label and image on one row, as ondevelop. - [ ] A match or associate choice with
<strong>Given</strong> <math><mi>x</mi></math> <em>solve</em>keeps both spaces with native MathML and with the MathJax fallback. - [ ] Two block children of a QTI component that are separated by a newline or
render as ondevelop.
AI usage
Claude Code found this while working on #15598, reproduced it in the QTI sandbox and drafted the report. I chose where the whitespace is kept and how Prompt and the chips lay it out, and Claude Code rewrote it as a task.
Rewritten as a task: SafeHTML keeps whitespace-only text nodes for registered components' children too, building on #16010. Prompt.vue wraps only runs of inline content, and match and associate chips use an inline container.