GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(parse): Parse   as white space by donmccurdy · Pull Request #3487 · josdejong/mathjs

Conversation

@donmccurdy

@donmccurdy donmccurdy commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

Updates parser to handle   as a whitespace character.

In #2199 I saw the suggestion of doing a regex search for other possible unicode whitespace characters. Running /^\s$/.test('\u00A0') does indeed work. With that change, I think I'm seeing a 5% hit on the parser benchmarks, but it's a small change and might not be a meaningful difference?

Currently this PR takes the simplest approach, c === '\u00A0', no regex, and adds a unit test.

Related:

  • Fixes mathjs.parse raises error if having nbsp space (ascii 160), not internal spaces (ascii 20) #2199
  • Fixes Mixed whitespace in expressions shows errors gtg922r/obsidian-numerals#106

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Don McCurdy
fix(parse): Parse   as white space
d439819
This was referenced Jun 2, 2025
mathjs.parse raises error if having nbsp space (ascii 160), not internal spaces (ascii 20) #2199
Closed
Mixed whitespace in expressions shows errors gtg922r/obsidian-numerals#106
Closed
@josdejong

josdejong commented Jun 4, 2025

Copy link
Copy Markdown
Owner

Thanks Don!

My thought was that there are more unicode space characters than just the common \u00A0, see https://unicode-explorer.com/articles/space-characters, and that using a regexp may be suitable for that.

Just supporting \u00A0 is the most common case though, and solves the issue in a pragmatic way. Thanks for checking the performance impact!

If needed we can add more space characters to the function in the future, and also, you can always override the parse.isWhitespace yourself or preprocess whitespaces of your expression with a regex.

donmccurdy reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@josdejong
josdejong merged commit f3587d8 into josdejong:develop Jun 4, 2025
@donmccurdy
donmccurdy deleted the fix/mixed-whitespace branch June 4, 2025 10:44
@josdejong

josdejong commented Jul 2, 2025

Copy link
Copy Markdown
Owner

Your fix is published now in v14.5.3, thanks again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@donmccurdy donmccurdy mentioned this pull request Jul 11, 2025
chore(tests): Add unit test for parsing mixed whitespace gtg922r/obsidian-numerals#107
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Mixed whitespace in expressions shows errors mathjs.parse raises error if having nbsp space (ascii 160), not internal spaces (ascii 20)

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@donmccurdy @josdejong
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.