Repository navigation
fix(author): store plain text boxes as plain text, though their fields list tags - #165
Merged
Merged
Conversation
…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 ' 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
Contributor
There was a problem hiding this comment.
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 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 |
Contributor
There was a problem hiding this comment.
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 |
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #164
Changes
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 ishtmland the field liststags. Both are exported from./core, for a tool beside the build.generator.mjs): written text is markup only wheretakesMarkupsays so; everything else is stored as plain text. Its problem messages name the kind the same way.checkContent) still goes bytags, as the content check keeps it.tags: the editor puts a default in unescaped, and the server filters it bytags(translate.mjs, comment only).plainText(value, note, { filtered })): in a plain box whose field liststags,'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.createTextputs a stored value back intovalue="…"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.H5P.QuestionSet.md, regenerated bysync:skill.introPage.title,endGame.messageand the two old greetings are nowtext, nothtml: …; the other type files came out unchanged.Testing
pnpm --filter @missing-elements/h5p-author test: 153 passed, browser tests included. New tests:takesMarkupandeditorWidgetagainst Question Set's and Speak the Words Set's field shapes;plainTextwithfiltered;<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.<div>World War II: Five Historic Events</div>; this branch shows the title alone.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
takesMarkupandeditorWidgetto./coreand an option toplainText, none of them breaking. After publishing:<div>. Its branchfix/build-page-file-namesis ready, with download names that keep umlauts.npx skills update -gfor the regenerated type file.Summary by cubic
Fixes text fields that list
tagsbut 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
takesMarkupandeditorWidgetdecide from the editor's widget whether a field holds markup; the build, its problem messages, and the type files use them.tags, as the content check and server keep them.tags, an apostrophe is stored as typed;",&,<, and>stay escaped and are noted.H5P.QuestionSet.md: the intro title, results heading, and two old greetings are nowtext, nothtml.design/author.mdcounts the pack's 1,252textfields 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.