Skip to content

Matrix inputs: support curly HTML brackets - #1849

Merged
sangwinc merged 4 commits into
maths:iss1848from
adamant-pwn:codex/matrix-curly-brackets
Aug 25, 2026
Merged

Matrix inputs: support curly HTML brackets#1849
sangwinc merged 4 commits into
maths:iss1848from
adamant-pwn:codex/matrix-curly-brackets

Conversation

@adamant-pwn

@adamant-pwn adamant-pwn commented Aug 24, 2026

Copy link
Copy Markdown

Summary

The question-level matrixparens option already accepts {, and STACK's TeX output renders matrices with curly braces. The fixed and variable-size HTML matrix inputs currently fall back to square brackets for that value.

This adds a matrixcurlybrackets style and selects it for both input types and their API metadata. The brace is stored as a small STACK plugin SVG and used as a CSS mask, so it scales to the input height while keeping a stable stroke width and inheriting the surrounding text colour. The same rule is included in styles.css and mobile.css.

There is no new question option or migration. Existing square, round, bar and no-bracket rendering is unchanged.

Screenshots

Fixed 2 × 2, fixed 4 × 1 and variable-size inputs rendered by a local patched STACK instance:

Curly brackets scaling across STACK matrix input types

The existing square and round choices alongside the new curly rendering:

Square, round and curly STACK matrix input brackets

These were captured from the local STACK API image 2025102100 with the patch applied; each widget was produced by the API renderer rather than reconstructed as static HTML.

Verification

  • Added focused rendering/API tests for fixed and variable-size inputs with matrixparens: '{'.
  • PHP syntax checks pass for both renderer classes and their test files.
  • Rendered locally through the standalone STACK API with fixed 2 × 2, fixed 4 × 1 and variable-size inputs.
  • Compared square, round and curly settings side by side; the existing styles remain unchanged.
  • Verified left-to-right and right-to-left placement in a browser.
  • Verified in a browser accessibility snapshot that the empty CSS pseudo-elements and mask add no accessible node or text; the matrix table, cells and inputs remain exposed normally.

@sangwinc
sangwinc changed the base branch from dev to iss1848 August 25, 2026 09:46
@sangwinc

Copy link
Copy Markdown
Member

Wow! Thanks @adamant-pwn that's been on my list for a very long time. Thank you for finally sorting this out.

@christianp

Copy link
Copy Markdown
Contributor

Is the shape of the brackets exposed to the accessibility tree at all?

The brace wrapper inherited right-to-left direction from the page, so logical inline-start and inline-end placed the unmirrored left brace on the right and the mirrored right brace on the left. Force the mathematical wrapper to remain left-to-right, matching STACK's matrix input contents, and protect the declaration from Moodle's RTL transformation. Apply the same fix to desktop and mobile CSS.
The iss1848 integration branch now includes PR maths#1847, which overlaps the matrix and variable-matrix renderers, API documentation, and tests changed here. Resolve those overlaps by retaining c()/r() CAS value-type support together with the curly-bracket renderer and its API value. This keeps PR maths#1849 conflict-free without rewriting its published history.
Moodle's CSS lint configuration rejects data: URLs, so the embedded SVG mask made the Grunt step fail. Store the brace path as pix/curlybracket.svg instead, reference it through Moodle's qtype_stack pix placeholder in styles.css, and use the equivalent relative URL in the directly served mobile stylesheet. This preserves the current-colour mask and RTL behavior while using Moodle's normal cacheable image pipeline.
@adamant-pwn

Copy link
Copy Markdown
Author

No; like the existing square, round and bar styles, it is CSS-only. matrixparens is a presentation option and does not change the input value, so I'd treat the brackets as decorative. If the delimiter style should be announced, it would be better to handle all styles and both matrix input types consistently in a follow-up PR rather than special-case curly braces here.

@sangwinc

Copy link
Copy Markdown
Member

Is the shape of the brackets exposed to the accessibility tree at all?

Do you have a recommendation with this issue @christianp?

@christianp

Copy link
Copy Markdown
Contributor

If the brackets were separate elements, instead of styled pseudoselectors, you could add an aria-label attribute describing the shape with something like "curly bracket" or "parenthesis".

@sangwinc
sangwinc merged commit 7b079fd into maths:iss1848 Aug 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants