Skip to content

Conversation

@eaglethrost
Copy link
Contributor

@eaglethrost eaglethrost commented Dec 10, 2025

PR App Fix RM-XYZ

🧰 Changes

  • Removes the guard in mdxish expression evaluation that prevented evaluation when no function context was provided. For context: The initial mdxish prototype included a default JSX context, which was actually unnecessary for basic expression evaluation. Hence, the guard is also not needed
  • A bit of cleanup of the expression evaluation codes
  • More tests for expression evaluation

🧬 QA & Testing

@eaglethrost eaglethrost marked this pull request as ready for review December 10, 2025 15:31
// These are not exhaustive, but are a good starting point
// We probably want to just use a library that'll load most of the common operations for us
export const DEFAULT_JSX_CONTEXT: JSXContext = {
uppercase: (value: string) => value.toUpperCase(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Struggling to understand why we're constructing a special context with these operations? If I understand correctly ES language features are already available when we eval the expressions. And I don't believe these functions are available in strict MDX so why/how would a user even know they exist?

Instead of Hello {uppercase("world")} I would instead write Hello {"world".toUpperCase()}
and instead of {add(1, 2)} I would write {1 + 2}
and so on...

Is there a requirement I'm missing here?

Copy link
Contributor Author

@eaglethrost eaglethrost Jan 2, 2026

Choose a reason for hiding this comment

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

No you are right, apologies, I've found that the issue was with another code that was skipping evaluation if no function context / parameter names are provided. We don't need to define the default contexts for evaluating, so that code check is actually not needed.

Added tests for the string functions you suggested in here

@eaglethrost eaglethrost changed the title fix(mdxish): set up default jsx context math operations to fix jsx not evaluated fix(mdxish): jsx braces not evaluating Jan 2, 2026
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using mix instead of mdxish since mix returns a string already (mix is basically stringified mdxish)

const contextKeys = Object.keys(context);
const contextValues = Object.values(context);

// If no context provided, leave expression as-is
Copy link
Contributor Author

@eaglethrost eaglethrost Jan 2, 2026

Choose a reason for hiding this comment

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

The problematic check that is now removed

Copy link
Contributor Author

@eaglethrost eaglethrost Jan 2, 2026

Choose a reason for hiding this comment

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

Moving some things around for cleanliness

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.

2 participants