Skip to content

Conversation

@eaglethrost
Copy link
Contributor

@eaglethrost eaglethrost commented Dec 10, 2025

PR App Fix RM-XYZ

🧰 Changes

The default JSX context variable, which defined the mathematical operation functions for the JSX preprocessing step, accidentally got removed during the mdxish release😢, resulting in math operations in brackets not being operated. This PR adds it back, defining the common math operations for now, and added tests to the preprocessing step.

We would most likely want either to define more function operations (ideally importing from a library and not having to define & choose functions ourselves) in the future. But honestly I think it's also worth re-thinking how we want to store this context information

🧬 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?

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