Skip to content

Minor bug fix -- adds consistent application of .trim() in breakstrings.js - #1629

Draft
DoctorHaitch wants to merge 1 commit into
Doenet:mainfrom
DoctorHaitch:2026-08-01-kgh-tupleListAnswersFix
Draft

Minor bug fix -- adds consistent application of .trim() in breakstrings.js#1629
DoctorHaitch wants to merge 1 commit into
Doenet:mainfrom
DoctorHaitch:2026-08-01-kgh-tupleListAnswersFix

Conversation

@DoctorHaitch

Copy link
Copy Markdown

Summary

This PR fixes inconsistent whitespace handling when parsing tuple/list component strings in breakstrings.js.

Specifically, .trim() was added to several component string parsing paths in:
packages/doenetml-worker-javascript/src/components/commonsugar/breakstrings.js

This brings the implementation into alignment across related parsing functions, ensuring component strings are treated consistently regardless of surrounding whitespace.

Motivation

Issue #1617 exposed cases where tuple/list parsing behavior differed depending on which helper function processed the input. Some code paths trimmed surrounding whitespace while others did not, leading to inconsistent parsing results and unexpected behavior.

By normalizing component strings with .trim() throughout the relevant parsing logic, tuple/list handling becomes more predictable and consistent.

Fixes #1617.

Changes

  • Added .trim() to several component string parsing operations in breakstrings.js
  • Aligned whitespace handling across tuple/list parsing functions
  • Removed inconsistencies between equivalent parsing paths
  • Improved robustness when tuple/list components contain leading or trailing whitespace

Impact

This is a low-risk change that affects preprocessing of component strings prior to parsing.

Expected benefits include:

Testing

Verified that tuple/list expressions containing leading and trailing whitespace are parsed consistently across the affected code paths and produce the same results as equivalent trimmed inputs.

@dqnykamp dqnykamp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great, can you add a regression test that fails without this change and passes with it?

For example, in boolean.test.ts, you could use this DoenetML

<boolean name="b">
  <tupleList>
    (1,0) (1,2)
  </tupleList>
  = <tupleList>(1,0) (1,2)</tupleList>
</boolean>

and assert that the value state variable of b is true.

@DoctorHaitch
DoctorHaitch marked this pull request as draft August 3, 2026 20:24
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.

[Bug]: tupleList Equality Depends on Position of Closing </tupleList> Tag

2 participants