Skip to content

fix(author): store plain text boxes as plain text, though their fields list tags - #165

Merged
alekswebnet merged 2 commits into
mainfrom
fix/author-plain-text-boxes
Nov 9, 2026
Merged

alekswebnet merged 2 commits into
mainfrom
fix/author-plain-text-boxes

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #164

Changes

  • The rule (packages/author/lib/text.mjs): editorWidget(field) is the widget H5P's editor draws a field with: widget ?? type, or for a ShowWhen, the widget inside it. takesMarkup(field) is true only where that widget is html and the field lists tags. Both are exported from ./core, for a tool beside the build.
  • The build (generator.mjs): written text is markup only where takesMarkup says so; everything else is stored as plain text. Its problem messages name the kind the same way.
    • Saved content (checkContent) still goes by tags, as the content check keeps it.
    • Defaults also still go by tags: the editor puts a default in unescaped, and the server filters it by tags (translate.mjs, comment only).
  • Apostrophes (plainText(value, note, { filtered })): in a plain box whose field lists tags, ' is stored as typed. The editor's box would write ', which H5P.Components 1.0.101 (upstream's newest) shows as written; the content check's filter keeps a bare apostrophe.
    • " stays ": ns.createText puts a stored value back into value="…" unescaped, so a bare quote would cut the text short in the editor.
    • &, < and > stay escaped, as the filter would escape them, with a note saying to write "and" and “ ” instead.
  • The type file: H5P.QuestionSet.md, regenerated by sync:skill. introPage.title, endGame.message and the two old greetings are now text, not html: …; the other type files came out unchanged.
  • design/author.md: the text rule now names the widget, plus a new point with the census and the apostrophe rule.

Testing

  • pnpm --filter @missing-elements/h5p-author test: 153 passed, browser tests included. New tests:
    • takesMarkup and editorWidget against Question Set's and Speak the Words Set's field shapes;
    • plainText with filtered;
    • a Question Set build: the title and results heading stored plain, the introduction still <p>, markup noted, and a German title with umlauts, „“, & and ".
  • pnpm --filter @missing-elements/h5p-skills test: 77 passed: the type files are current, and every example builds and plays untrusted.
  • pnpm --filter @missing-elements/h5p-author typecheck: clean.
  • The same Question Set source, played by the verifier:
    • 0.5.0's cover shows <div>World War II: Five Historic Events</div>; this branch shows the title alone.
    • A German title with umlauts and ß, and "Germany's Surrender", show correctly, played trusted and untrusted, with no warnings.
  • Umlauts are stored as typed throughout. Neither the editor nor the platforms escape them, and the test above covers them.

Not verified: the results page in a browser (the stored value is tested, and ResultScreen draws it with textContent, as the cover does), and a Moodle upload of a fixed package.

Release

A fix, so author 0.5.1. It also adds takesMarkup and editorWidget to ./core and an option to plainText, none of them breaking. After publishing:

  • embed-my.github.io's build page needs the bump, still on 0.5.0 and showing the <div>. Its branch fix/build-page-file-names is ready, with download names that keep umlauts.
  • Run npx skills update -g for the regenerated type file.

Summary by cubic

Fixes text fields that list tags but are plain text boxes in H5P's editor being stored as markup, which showed <div>World War II: Five Historic Events</div> on Question Set's cover.

Bug Fixes

  • New takesMarkup and editorWidget decide from the editor's widget whether a field holds markup; the build, its problem messages, and the type files use them.
  • Saved content and defaults still go by tags, as the content check and server keep them.
  • In a plain box whose field lists tags, an apostrophe is stored as typed; ", &, <, and > stay escaped and are noted.
  • Regenerated H5P.QuestionSet.md: the intro title, results heading, and two old greetings are now text, not html.
  • A census in design/author.md counts the pack's 1,252 text fields whatever widget draws them, and names these five as the only ones stored otherwise than their widgets store them.

Written for commit 7c2c681. Summary will update on new commits.

View guided diff Turn on auto-fix

…s list tags

The build took any text field that lists tags for markup and wrapped plain
text in it in <div>. H5P's editor decides by widget: only the rich-text
widget, html, writes markup; its plain box stores htmlspecialchars(value)
and wraps nothing. Question Set 1.21 has five such plain boxes, and draws
its intro title and results heading with textContent, so learners saw
<div>World War II: Five Historic Events</div>.

- takesMarkup and editorWidget (text.mjs, exported from ./core): markup
  only where the editor's widget is html, a ShowWhen around one included,
  and the field lists tags; used by the build, its messages and schemaOf.
- Saved content and defaults still go by tags, as the content check and
  the server keep them.
- plainText's filtered option: in a plain box whose field lists tags an
  apostrophe is stored as typed, since the editor's &#39; shows as
  written there; ", &, < and > stay escaped, and are noted.
- H5P.QuestionSet.md regenerated: the four fields are text, not html.

Of the pack's 1,252 text fields these five were the only ones stored
otherwise than their widget stores them.

Closes #164
@alekswebnet alekswebnet added the bug Something isn't working label Nov 9, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="design/author.md">

<violation number="1" location="design/author.md:57">
P3: This count includes colour selectors, a date, and hidden fields, so these are not 1,252 text fields; call them fields.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread design/author.md Outdated
Comment on lines +57 to +58
content is still checked by `tags`, as the content check keeps it. Of the pack's 1,252 text
fields, these five were the only ones that differed: the other 1,096 plain boxes and the 96

@cubic-dev-ai cubic-dev-ai Bot Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This count includes colour selectors, a date, and hidden fields, so these are not 1,252 text fields; call them fields.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At design/author.md, line 57:

<comment>This count includes colour selectors, a date, and hidden fields, so these are not 1,252 text fields; call them fields.</comment>

<file context>
@@ -37,14 +37,37 @@ to 3,000. Twelve things the code does not say by itself:
+  H5P.Components' `textContent`, so a quiz from ChatGPT showed `<div>World War II: Five Historic
+  Events</div>` on its cover, and the type file had told the model both fields take HTML.
+  `takesMarkup` is now the rule, in the build, in its messages and in the type files; saved
+  content is still checked by `tags`, as the content check keeps it. Of the pack's 1,252 text
+  fields, these five were the only ones that differed: the other 1,096 plain boxes and the 96
+  rich-text fields (Speak the Words Set's ShowWhen among them) were stored as their widgets store
</file context>
Suggested change
content is still checked by `tags`, as the content check keeps it. Of the pack's 1,252 text
fields, these five were the only ones that differed: the other 1,096 plain boxes and the 96
content is still checked by `tags`, as the content check keeps it. Of the pack's 1,252 fields,
these five were the only ones that differed: the other 1,096 plain boxes and the 96
Fix with cubic

…ver their widget

The review read the 1,252 as excluding colour selectors, the date and the
hidden fields; all are fields of type text, drawn by other widgets, out
of the pack's 2,361 fields. Say so, and rewrap the paragraph.
@alekswebnet alekswebnet self-assigned this Nov 9, 2026
@alekswebnet
alekswebnet merged commit 72468f7 into main Nov 9, 2026
10 checks passed
@alekswebnet
alekswebnet deleted the fix/author-plain-text-boxes branch November 12, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

h5p-author wraps Question Set's intro title and results heading in <div>, which learners see

1 participant